/* Lagos Swipe: parchment, ink and ochre, same family as portrait-js's Atelier. Mobile first. */
:root {
  --ink: #1a1410; --ink-soft: #3b2f25; --paper: #f6eed9; --parch: #ead8b0; --ochre: #c99a4b; --ochre-deep: #a8762a;
  --teal: #2f5f6e; --rust: #a8462c; --green: #1b6b4a; --red: #b3262a;
  --wobbly: 255px 14px 225px 14px / 14px 225px 14px 255px;
  --font-hand: 'Kalam', 'Segoe Print', 'Comic Sans MS', cursive; --font-marker: 'Permanent Marker', 'Kalam', cursive;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-hand); color: var(--ink); background: var(--parch); overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
  background-image: radial-gradient(ellipse at 50% 40%, rgba(255,248,228,.55), rgba(255,248,228,0) 55%), radial-gradient(ellipse at 50% 50%, rgba(120,78,28,0) 60%, rgba(120,78,28,.32));
}
body::before { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: url('../portrait-js/img/wrinkled-paper.jpg') center / cover; mix-blend-mode: multiply; opacity: .7; }
button { font: inherit; color: inherit; cursor: pointer; }
.app { position: relative; max-width: 480px; height: 100dvh; margin: 0 auto; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
[hidden] { display: none !important; }

/* ---- HUD ---- */
.hud { position: relative; z-index: 3; padding: 10px 14px 6px; }
.hud-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 42px; }
.hud-btn { background: none; border: 0; padding: 0; text-align: left; min-width: 0; }
.hud-age b { display: block; font-family: var(--font-marker); font-weight: 400; font-size: 1.35rem; line-height: 1; letter-spacing: .04em; }
.hud-age small { display: block; font-size: .8rem; color: var(--ink-soft); max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-money { font-family: var(--font-marker); font-size: 1.3rem; color: var(--green); background: #fffaf0; border: 3px solid var(--ink); border-radius: 8px; padding: 1px 14px; box-shadow: 0 3px 0 rgba(26,20,16,.2); cursor: pointer; }
.hud-money::after { content: '+'; margin-left: 8px; padding: 0 5px; border-radius: 50%; background: var(--green); color: #fffaf0; font-size: 1rem; }
.hud-money:active { transform: translateY(2px); box-shadow: none; }
.hud-cash { position: relative; }
.hud-money { position: relative; }
.hud-money::before { content: 'CASH'; position: absolute; top: -9px; left: 8px; font: 400 .6rem/1 var(--font-marker); letter-spacing: .08em; color: var(--ink); background: var(--ochre); border: 2px solid var(--ink); border-radius: 5px; padding: 2px 5px 1px; transform: rotate(-3deg); }
.money-flash { position: absolute; left: 50%; top: 100%; margin-top: 6px; transform: translateX(-50%); display: grid; justify-items: center; gap: 3px; pointer-events: none; z-index: 6; white-space: nowrap; }
.money-flash b, .money-flash small { padding: 1px 9px; border: 2px solid var(--ink); border-radius: 9px; background: #fffaf0; animation: moneyIn .25s cubic-bezier(.2,1.5,.4,1) both; box-shadow: 0 2px 0 rgba(26,20,16,.22); }
.money-flash b { font: 400 1.15rem var(--font-marker); }
.money-flash small { font: 700 .72rem var(--font-hand); animation-delay: .35s; }
.money-flash .up { color: var(--green); } .money-flash .down { color: var(--red); }
@keyframes moneyIn { from { opacity: 0; transform: translateY(-8px) scale(.8); } to { opacity: 1; transform: none; } }
.hud-right { display: flex; gap: 8px; }
.icon-btn { position: relative; width: 38px; height: 38px; border: 2.5px solid var(--ink); border-radius: 6px; background: #fffaf0; padding: 0; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(26,20,16,.2); }
.icon-btn:active { transform: translateY(2px); box-shadow: none; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#inbox-badge { position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font: 700 .7rem/14px var(--font-hand); font-style: normal; text-align: center; border: 2px solid var(--ink); }

@property --v { syntax: '<number>'; inherits: true; initial-value: 50; }
@property --pv { syntax: '<number>'; inherits: true; initial-value: 50; }
.bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.bar { --c: #4aa36b; --v: 50; --pv: 50; --tint: transparent; position: relative; display: grid; justify-items: center; gap: 5px; transition: --v .6s ease-out, --pv .18s ease-out; }
.bar[data-stat=wallet] { --c: #4aa36b; } .bar[data-stat=heart] { --c: #e0607a; } .bar[data-stat=hustle] { --c: #e0aa2c; } .bar[data-stat=peace] { --c: #4e8fc7; }
.bar.gain { --tint: rgba(255,250,240,.85); } .bar.loss { --tint: #b3262a; }
.bar .badge { position: relative; width: 54px; height: 54px; border-radius: 50%; background: #fffaf0; border: 3px solid var(--ink); box-shadow: 0 3px 0 rgba(26,20,16,.25); overflow: hidden; }
.bar .level { position: absolute; inset: 0; background: linear-gradient(to top, var(--c) calc(min(var(--v), var(--pv)) * 1%), var(--tint) calc(min(var(--v), var(--pv)) * 1%) calc(max(var(--v), var(--pv)) * 1%), transparent calc(max(var(--v), var(--pv)) * 1%)); }
.bar svg.face { position: absolute; inset: 0; width: 100%; height: 100%; fill: #fffaf0; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; paint-order: stroke; }
.bar svg .ico-text { fill: #fffaf0; stroke: var(--ink); stroke-width: 2.4; font-family: var(--font-marker); }
.bar[data-stat=hustle] svg.face rect, .bar[data-stat=hustle] svg.face path, .bar[data-stat=peace] svg.face path { fill: none; stroke: var(--ink); stroke-width: 3; }
.bar .lbl { font: 400 .85rem var(--font-marker); letter-spacing: .02em; }
.bar.danger .badge { border-color: var(--red); animation: wobble .45s infinite alternate; }
.bar.danger .lbl { color: var(--red); }
.arrow { position: absolute; top: -9px; left: 50%; transform: translateX(-50%) scale(0); font: 400 .66rem/1 var(--font-marker); letter-spacing: -1px; padding: 2px 5px; border: 2px solid var(--ink); border-radius: 9px; background: #fffaf0; color: var(--green); z-index: 3; white-space: nowrap; pointer-events: none; transition: transform .14s cubic-bezier(.3,1.6,.5,1); }
.arrow.dn { color: var(--red); }
.arrow.a1, .arrow.a2, .arrow.a3 { transform: translateX(-50%) scale(1); }
.arrow.a1::before { content: '▲'; } .arrow.a2::before { content: '▲▲'; } .arrow.a3::before { content: '▲▲▲'; }
.arrow.dn.a1::before { content: '▼'; } .arrow.dn.a2::before { content: '▼▼'; } .arrow.dn.a3::before { content: '▼▼▼'; }
.delta { position: absolute; top: 14px; left: 50%; font: 400 1.25rem var(--font-marker); opacity: 0; pointer-events: none; text-shadow: 0 0 3px var(--paper), 0 0 3px var(--paper), 0 0 3px var(--paper); z-index: 4; }
.delta.show { animation: rise 1.1s ease-out; } .delta.up { color: var(--green); } .delta.down { color: var(--red); }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 0); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -52px); } }
@keyframes wobble { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }

/* ---- stage & card ---- */
.stage { position: relative; display: grid; place-items: center; padding: 40px 16px 10px; min-height: 0; }
.warn { position: absolute; top: 2px; left: 50%; transform: translateX(-50%) rotate(-.8deg); z-index: 4; max-width: calc(100% - 40px); width: max-content; display: flex; align-items: center; gap: 7px; background: #f7dd9a; border: 2.5px solid var(--ink); border-radius: 4px 9px 4px 9px; padding: 3px 12px 3px 5px; font-size: .84rem; line-height: 1.15; box-shadow: 0 3px 0 rgba(26,20,16,.22); }
.warn::before { content: '!'; flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; background: var(--rust); color: #fffaf0; border: 2px solid var(--ink); font: 400 .85rem/16px var(--font-marker); text-align: center; }
.warn.crit { background: #f2b3a4; animation: wobbleW .55s infinite alternate; }
@keyframes wobbleW { from { transform: translateX(-50%) rotate(-1.6deg); } to { transform: translateX(-50%) rotate(1.2deg); } }
.stack { --p: 0; --pa: 0; position: relative; width: 100%; max-width: 372px; height: 100%; max-height: 560px; }
.card {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px 12px 14px; background: var(--paper);
  border: 3px solid var(--ink); border-radius: 6px 10px 6px 12px; box-shadow: 0 8px 0 rgba(26,20,16,.2), 0 14px 22px rgba(60,36,10,.18); touch-action: pan-y; user-select: none; -webkit-user-select: none;
  cursor: grab; transform-origin: 50% 135%; will-change: transform; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}
/* On a short screen the whole card scrolls: the picture gives up space down to a floor, then the words and the
   rest slide up. pan-y keeps a vertical finger for scrolling while a horizontal one still reaches the swipe. */
.card > * { flex-shrink: 0; }
.card.scrollable { box-shadow: 0 8px 0 rgba(26,20,16,.2), 0 14px 22px rgba(60,36,10,.18), inset 0 -16px 12px -12px rgba(26,20,16,.45); }
.card.dragging { cursor: grabbing; }
.card.deal { animation: deal .5s cubic-bezier(.2,.85,.3,1) both; }
@keyframes deal {
  0% { transform: translate3d(-120%, -88%, 0) rotate(-26deg) scale(.88); opacity: 0; }
  14% { opacity: 1; }
  68% { transform: translate3d(1.5%, 1%, 0) rotate(1.6deg) scale(1.008); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.who-block { min-width: 0; }
.card-head .who { display: block; font: 400 1.25rem/1.05 var(--font-marker); text-transform: uppercase; letter-spacing: .03em; }
.card-head .sub { display: block; font-size: .92rem; font-style: italic; color: var(--ink-soft); }
.place { flex: 0 0 auto; width: 40px; height: 40px; border: 3px solid var(--ink); border-radius: 50%; overflow: hidden; background: var(--parch); box-shadow: 0 2px 0 rgba(26,20,16,.25); }
.place svg { width: 100%; height: 100%; display: block; }
.tag.real { font-size: .7rem; font-weight: 700; background: var(--teal); color: #fff; padding: 1px 8px; border-radius: 10px; border: 2px solid var(--ink); white-space: nowrap; }
.picture { position: relative; flex: 1 0 110px; min-height: 110px; border: 3px solid var(--ink); border-radius: 4px; background: #dcc590 url('../portrait-js/img/wrinkled-paper.jpg') center / cover; background-blend-mode: multiply; overflow: hidden; box-shadow: inset 0 0 0 3px #fffaf0; }
.picture::after { content: ''; position: absolute; inset: 0; background: var(--wash, linear-gradient(#f2e3be, #cfb27a)); mix-blend-mode: multiply; opacity: .5; pointer-events: none; z-index: 2; }
.portrait { position: absolute; inset: 0; display: flex; justify-content: center; align-items: flex-end; }
.portrait-canvas { display: block; height: 100%; width: auto; max-width: 100%; object-fit: contain; pointer-events: none; }
/* portrait-js draws a 4:5 bust with a lot of paper round it; the card frame is short and wide, so crop in on
   the head and shoulders. 1.4 about a point just above the middle keeps even a tall gele inside the picture. */
.picture .portrait-canvas { transform: scale(1.4); transform-origin: 50% 45%; }
.portrait.art svg { width: 100%; height: 100%; display: block; }
.skyline { position: absolute; left: 0; right: 0; bottom: 0; height: 24%; color: var(--ink); opacity: .2; mix-blend-mode: multiply; pointer-events: none; z-index: 1; }
.skyline svg { width: 100%; height: 100%; display: block; }
.avatar-chip { position: absolute; right: 6px; bottom: 6px; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--ink); background: #fffaf0; object-fit: cover; }
.line { margin: 0; font-size: 1.12rem; line-height: 1.28; min-height: 3.4em; }
/* The caption is part of the card's own scroll, so a long story is never clipped. */
.card-text { flex: 0 0 auto; }
.card-text .line { min-height: 0; }
.recall { margin: 0; font-size: .82rem; font-style: italic; color: var(--rust); line-height: 1.2; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: .8rem; padding: 1px 9px; border: 2px solid var(--ink); border-radius: 12px; background: #fffaf0; font-family: inherit; }
.stamp { position: absolute; top: 74px; max-width: 62%; font: 400 1.2rem/1.1 var(--font-marker); text-transform: uppercase; letter-spacing: .04em; border: 3px solid; padding: 3px 10px; border-radius: 6px; background: rgba(255,250,240,.9); opacity: 0; pointer-events: none; z-index: 5; }
.stamp.sr { left: 16px; color: var(--green); transform: rotate(-9deg); opacity: calc((var(--p) - .1) * 1.9); }
.stamp.sl { right: 16px; color: var(--red); transform: rotate(9deg); opacity: calc((var(--p) * -1 - .1) * 1.9); }
.toast { position: absolute; left: 50%; top: 92px; transform: translate(-50%, -14px); max-width: 90%; background: var(--ink); color: var(--paper); padding: 6px 14px; border-radius: 14px; font-size: .95rem; opacity: 0; transition: .25s; pointer-events: none; z-index: 6; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.avatar-chip { z-index: 3; }

/* ending: a proper lose (or win) screen */
/* An ending is not swiped, so the whole card scrolls and is read like a letter. */
.kind-ending { cursor: default; overflow-y: auto; }
.kind-ending > * { flex-shrink: 0; }
.kind-ending .picture { flex: 0 0 150px; }
.stamp-big { position: absolute; top: 132px; left: 50%; transform: translateX(-50%) rotate(-8deg); font: 400 2rem var(--font-marker); letter-spacing: .06em; padding: 2px 16px; border: 5px solid; border-radius: 8px; background: rgba(255,250,240,.88); z-index: 4; white-space: nowrap; animation: stampIn .35s cubic-bezier(.2,1.6,.4,1); }
.stamp-big.bad { color: var(--red); } .stamp-big.good { color: var(--green); }
@keyframes stampIn { from { transform: translateX(-50%) rotate(-8deg) scale(2.4); opacity: 0; } to { transform: translateX(-50%) rotate(-8deg) scale(1); opacity: 1; } }
.end-title { margin: 4px 0 0; font: 400 1.7rem var(--font-marker); text-align: center; text-transform: uppercase; }
.kind-ending .line { min-height: 0; font-size: 1rem; }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; font-size: .88rem; }
.summary .srow { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--ochre); }
.remembered { font-size: .85rem; border-top: 2px dashed var(--ochre); padding-top: 4px; } .remembered p { margin: 2px 0; }

/* ---- dock: you, and the two postcards ---- */
.dock { display: grid; grid-template-columns: 60px 1fr; gap: 12px; align-items: end; padding: 6px 14px 14px; }
.me-corner { position: relative; width: 60px; height: 76px; padding: 0; border: 3px solid var(--ink); border-radius: 4px; background: var(--parch); transform: rotate(-3deg); box-shadow: 0 4px 0 rgba(26,20,16,.2); }
.me-corner:active { transform: rotate(-3deg) translateY(2px); }
.me-corner canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
.me-corner img { position: absolute; right: -9px; top: -9px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); background: #fffaf0; object-fit: cover; }
.me-tag { position: absolute; bottom: -9px; left: 50%; transform: translateX(-50%); background: var(--ochre); border: 2px solid var(--ink); font: 400 .72rem var(--font-marker); padding: 0 8px; border-radius: 4px; }
.postcards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.postcard { --c: var(--red); position: relative; padding: 5px 5px 0; background: #fffaf0; border: 3px solid var(--ink); border-radius: 4px; box-shadow: 0 5px 0 rgba(26,20,16,.22); transform: rotate(-2.2deg); text-align: center;
  transition: transform .18s cubic-bezier(.3,1.6,.5,1), opacity .15s, filter .15s; overflow: hidden; }
.postcard.pc-r { --c: var(--green); transform: rotate(2.2deg); }
.postcard:active { box-shadow: 0 1px 0 rgba(26,20,16,.22); }
.postcard.lift { transform: translateY(-12px) rotate(0) scale(1.07); z-index: 2; box-shadow: 0 12px 0 rgba(26,20,16,.16); }
.postcard.dim { opacity: .55; filter: saturate(.55); transform: translateY(2px) rotate(0) scale(.97); }
.pc-art { display: block; aspect-ratio: 10 / 6.4; border: 2px solid var(--ink); overflow: hidden; }
.pc-art svg { width: 100%; height: 100%; display: block; }
.pc-money { position: absolute; top: 9px; right: 9px; z-index: 2; font: 400 .85rem/1 var(--font-marker); padding: 3px 7px 2px; border: 2px solid var(--ink); border-radius: 8px; background: #fffaf0; box-shadow: 0 2px 0 rgba(26,20,16,.25); }
.pc-money:empty { display: none; } .pc-money.up { color: var(--green); } .pc-money.down { color: var(--red); }
.pc-lbl { display: grid; place-items: center; margin: 5px -5px 0; padding: 3px 6px; min-height: 2.5em; background: var(--c); color: #fffaf0; font: 400 .98rem/1.1 var(--font-marker); border-top: 3px solid var(--ink); text-shadow: 0 1px 0 rgba(26,20,16,.4); }
.postcards.swap .postcard { animation: pcIn .34s cubic-bezier(.2,1.4,.4,1) both; }
.postcards.swap .pc-r { animation-delay: .05s; }
@keyframes pcIn { from { opacity: 0; translate: 0 26px; } to { opacity: 1; translate: 0 0; } }

/* ---- sheets ---- */
.scrim { position: fixed; inset: 0; background: rgba(26,20,16,.45); z-index: 10; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px; max-height: 86dvh; z-index: 11; display: flex; flex-direction: column;
  background: var(--paper); border: 3px solid var(--ink); border-bottom: 0; border-radius: 22px 18px 0 0; animation: up .25s ease-out; }
.sheet.full { height: 94dvh; max-height: 94dvh; }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 6px; border-bottom: 2px dashed var(--ochre); }
.sheet-head h2 { margin: 0; font: 400 1.3rem var(--font-marker); }
.spacer { width: 38px; }
.sheet-body { overflow-y: auto; padding: 10px 14px 24px; flex: 1; -webkit-overflow-scrolling: touch; }
.block { margin: 12px 0; } .block h3 { margin: 0 0 6px; font: 400 1.05rem var(--font-marker); color: var(--ochre-deep); }
.muted { color: var(--ink-soft); } .fine { font-size: .75rem; color: var(--ink-soft); } .center { text-align: center; } .lead { font-size: 1.05rem; }
.btn { border: 3px solid var(--ink); border-radius: var(--wobbly); background: #fffaf0; padding: 7px 14px; font-weight: 700; box-shadow: 0 3px 0 rgba(26,20,16,.2); }
.btn.primary { background: var(--ochre); } .btn.small { padding: 3px 10px; font-size: .85rem; } .btn:disabled { opacity: .5; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; } .actions .btn { flex: 1; }
.hero { display: flex; gap: 12px; align-items: center; } .hero-portrait { position: relative; width: 130px; flex: 0 0 auto; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; background: var(--parch); }
.hero-portrait.big { width: 190px; margin: 0 auto; } .hero-portrait canvas { width: 100%; height: auto; display: block; }
.hero-text h3 { margin: 0; font: 400 1.4rem var(--font-marker); } .hero-text p { margin: 2px 0; }
.rows { margin-top: 12px; } .lrow { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--ochre); }
.lrow .k { width: 74px; font-weight: 700; color: var(--ochre-deep); } .lrow .v { display: flex; gap: 8px; align-items: center; } .lrow small { display: block; color: var(--ink-soft); }
.mini { width: 44px; } .thumb { width: 100%; } .thumb canvas, .mini canvas { width: 100%; height: auto; display: block; border: 2px solid var(--ink); border-radius: 6px; }
.srow2 { display: grid; grid-template-columns: 70px 1fr; gap: 2px 8px; align-items: center; margin-bottom: 6px; } .srow2 small { grid-column: 2; color: var(--ink-soft); }
.track { height: 12px; border: 2px solid var(--ink); border-radius: 8px; background: #fffaf0; overflow: hidden; } .fill { display: block; height: 100%; }
.f-wallet { background: #7fc08f; } .f-heart { background: #e9808a; } .f-hustle { background: var(--ochre); } .f-peace { background: #7fb2c0; }
.legacy { display: flex; justify-content: space-around; margin-top: 10px; padding: 8px; border: 2px dashed var(--ochre); border-radius: 12px; }
.list { display: grid; gap: 6px; } .item { display: flex; gap: 10px; align-items: center; text-align: left; padding: 6px 8px; border: 2px solid var(--ink); border-radius: 12px; background: #fffaf0; position: relative; width: 100%; }
.item .thumb { width: 52px; flex: 0 0 auto; } .item-text { flex: 1; min-width: 0; } .item-text b, .item-text small { display: block; } .item-text small { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.unread { border-color: var(--red); } .item.me { background: #fbe8b8; } .dot-new { width: 12px; height: 12px; border-radius: 50%; background: var(--red); border: 2px solid var(--ink); }
.rank { width: 34px; } .pts { font-family: var(--font-marker); font-weight: 400; }
.chat-head { display: flex; align-items: center; gap: 10px; } .chat-head .thumb { width: 56px; } .chat-head .btn { margin-left: auto; }
.msgs { display: flex; flex-direction: column; gap: 6px; max-height: 34dvh; overflow-y: auto; padding: 10px 2px; }
.msg { max-width: 82%; padding: 6px 10px; border: 2px solid var(--ink); border-radius: 14px; background: #fffaf0; } .msg small { display: block; font-size: .7rem; color: var(--ink-soft); }
.msg.me { align-self: flex-end; background: var(--ochre); } .msg.them { align-self: flex-start; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; } .btn-chip { cursor: pointer; }
.chips.pick .chip.on, .btn-chip:active { background: var(--ochre); }
.segment { display: flex; border: 3px solid var(--ink); border-radius: var(--wobbly); overflow: hidden; } .segment button { flex: 1; border: 0; background: #fffaf0; padding: 6px; font-weight: 700; } .segment button.on { background: var(--ochre); }

/* ---- customiser ---- */
.cz-preview { position: relative; width: 150px; margin: 4px auto 8px; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; background: var(--parch); } .cz-preview canvas { width: 100%; display: block; }
/* your face stays put while you scroll the options: the bar spans the sheet so nothing shows behind it */
.cz-sticky { position: sticky; top: 0; z-index: 4; margin: -10px -14px 6px; padding: 6px 14px 8px; background: var(--paper); box-shadow: 0 6px 6px -6px rgba(26,20,16,.45); }
.cz-sticky .cz-preview { margin: 0 auto; }
.cz-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; } .cz-tabs button { flex: 0 0 auto; border: 2px solid var(--ink); border-radius: 12px; background: #fffaf0; padding: 4px 10px; font-weight: 700; } .cz-tabs button.on { background: var(--ochre); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.tcell { padding: 2px; border: 2px solid var(--ink); border-radius: 10px; background: #fffaf0; } .tcell.on { background: var(--ochre); } .tcell canvas { width: 100%; height: auto; display: block; border-radius: 6px; } .tcell small { display: block; font-size: .68rem; line-height: 1.1; min-height: 1.6em; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; } .sw { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ink); padding: 0; } .sw.on { outline: 3px solid var(--ochre-deep); outline-offset: 2px; }
.slider { display: grid; grid-template-columns: 100px 1fr; gap: 8px; align-items: center; margin: 4px 0; } .slider input { width: 100%; accent-color: var(--ochre-deep); }
.field { display: grid; gap: 2px; margin: 8px 0; font-weight: 700; } .field select { padding: 8px; border: 2px solid var(--ink); border-radius: 10px; background: #fffaf0; font: inherit; }

/* ---- shop ---- */
.stash { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; margin-bottom: 4px; }
.stash > div { padding: 6px 4px; border: 2px dashed var(--ochre); border-radius: 12px; background: #fffaf0; }
.stash b { display: block; font: 400 1.5rem/1.1 var(--font-marker); color: var(--green); }
.stash small { color: var(--ink-soft); }
.stash em { display: block; margin-top: 3px; font-size: .72rem; font-style: normal; line-height: 1.15; color: var(--ink-soft); }
.item.pack { align-items: center; }
.item.pack .price { flex: 0 0 auto; padding: 4px 12px; border: 2px solid var(--ink); border-radius: 10px; background: var(--ochre); font: 400 1rem var(--font-marker); white-space: nowrap; }
.item.pack.real .price { background: var(--green); color: #fffaf0; }
.item.pack:disabled { opacity: .55; }
.item.pack:disabled .price { background: transparent; }
.item.pack .item-text small { white-space: normal; }
.linkbtn { padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--ochre-deep); text-decoration: underline; cursor: pointer; }

/* ---- splash ---- */
.splash { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; overflow: hidden; text-align: center; transition: opacity .35s;
  background: radial-gradient(circle at 1px 1px, rgba(120,78,28,.16) 1.4px, transparent 1.8px) 0 0 / 14px 14px, radial-gradient(ellipse at 50% 45%, #fff4d6 0, #ead8b0 55%, #cfae72 100%); }
.splash.gone { opacity: 0; pointer-events: none; }
.app[data-screen=loading] .hud, .app[data-screen=loading] .dock { visibility: hidden; }
@media (min-width: 560px) { .app { border-left: 3px solid var(--ink); border-right: 3px solid var(--ink); background: rgba(246,238,217,.35); } }
@media (max-height: 700px) { .bar .badge { width: 46px; height: 46px; } .line { font-size: 1rem; min-height: 3em; } .hud-top { min-height: 36px; } .bars { margin-top: 8px; } .pc-lbl { font-size: .88rem; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* canvases outside the card frame size by width, not height */
.tcell canvas, .thumb canvas, .hero-portrait canvas, .cz-preview canvas, .mini canvas { height: auto; max-height: none; width: 100%; aspect-ratio: 4 / 5; mix-blend-mode: normal; }
.tcell { display: flex; flex-direction: column; align-items: stretch; }

/* ---- people & memories ---- */
.people { display: grid; gap: 8px; }
.person { display: flex; gap: 10px; padding: 8px; border: 2px solid var(--ink); border-radius: 10px; background: #fffaf0; }
.person .thumb { width: 56px; flex: 0 0 auto; }
.person-text { flex: 1; min-width: 0; } .person-text b { font-size: 1.05rem; } .person-text small { display: block; color: var(--ink-soft); }
.meter { height: 10px; margin: 4px 0 2px; border: 2px solid var(--ink); border-radius: 6px; background: #efe3c4; overflow: hidden; }
.meter .fill { display: block; height: 100%; } .fill.good { background: #6dbb86; } .fill.ok { background: var(--ochre); } .fill.bad { background: #d9695b; }
.person .mem { margin: 2px 0 0; font-size: .85rem; font-style: italic; color: var(--rust); }

.story-tab { position: absolute; left: 0; top: 10px; z-index: 3; display: flex; align-items: center; gap: 6px; max-width: 80%; padding: 2px 10px 2px 6px; background: var(--ochre); color: var(--ink); border: 2.5px solid var(--ink); border-left: 0; border-radius: 0 8px 8px 0;
  font: 400 .8rem/1.1 var(--font-marker); letter-spacing: .03em; text-transform: uppercase; box-shadow: 0 2px 0 rgba(26,20,16,.25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-tab i { flex: 0 0 auto; width: 8px; height: 8px; background: var(--ink); transform: rotate(45deg); }
.vig path, .vig rect, .vig circle, .vig ellipse { vector-effect: non-scaling-stroke; }
.vig g[fill=none], .vig g[stroke] { stroke-width: 2.4px; }
.portrait.art svg.vig { width: 100%; height: 100%; display: block; }

/* people & stories sheet */
.story-row { margin: 0 0 12px; padding: 8px 10px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fffaf0; box-shadow: 0 3px 0 rgba(26,20,16,.15); }
.story-row h4 { margin: 0; font: 400 1.05rem var(--font-marker); display: flex; justify-content: space-between; gap: 8px; }
.story-row .st { font: 400 .72rem var(--font-marker); padding: 1px 8px; border: 2px solid var(--ink); border-radius: 10px; background: var(--ochre); text-transform: uppercase; align-self: center; }
.story-row .st.done { background: #8fd69a; } .story-row .st.failed { background: #f2b3a4; }
.story-row ol { margin: 6px 0 0; padding-left: 18px; font-size: .88rem; } .story-row li { margin: 2px 0; }
.story-row li:last-child { font-weight: 700; }

.sheet-body h3.sec { margin: 10px 0 6px; font: 400 1.05rem var(--font-marker); color: var(--ochre-deep); }

/* ---- the sticker wall ---- */
.stickers { position: absolute; inset: 0; pointer-events: none; }
.stk { position: absolute; translate: -50% -50%; rotate: var(--r, 0deg); container-type: inline-size; filter: drop-shadow(2px 4px 0 rgba(26,20,16,.38)); animation: slap .55s cubic-bezier(.2,1.4,.4,1) both; animation-delay: var(--d, 0ms); }
@keyframes slap { from { scale: 2.3; opacity: 0; rotate: calc(var(--r) - 28deg); } 55% { opacity: 1; } to { scale: 1; opacity: 1; rotate: var(--r); } }
.stk-in { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; background: #fffaf0; border: 5px solid #fffaf0; outline: 2px solid rgba(26,20,16,.28); }
.stk.round .stk-in { border-radius: 50%; } .stk.tile .stk-in { border-radius: 16%; }
.stk-in::after { content: ''; position: absolute; inset: 0; background: linear-gradient(118deg, transparent 38%, rgba(255,255,255,.4) 48%, transparent 58%); pointer-events: none; }
.stk-face canvas { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; max-height: none; mix-blend-mode: normal; }
.stk-art svg { display: block; width: 100%; height: 100%; }
.stk-star .stk-in { background: none; border: 0; outline: 0; } .stk-star .stk-in::after { display: none; } .stk-star svg { width: 100%; height: 100%; }
.stk.slogan .stk-in { aspect-ratio: auto; border-radius: 12px; padding: 5% 7%; font: 400 var(--fs, 20cqw)/1.05 var(--font-marker); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
.stk.slogan .stk-in::after { display: none; }
.stk.coin .stk-in { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font: 400 var(--fs, 62cqw)/1 var(--font-marker); padding: 0; }
.splash-inner { position: relative; z-index: 12; }
.splash h1 { margin: 0 0 12px; font: 400 clamp(3.4rem, 17vw, 4.8rem)/.92 var(--font-marker); letter-spacing: .03em; text-transform: uppercase; color: #1c1410; transform: rotate(-4deg);
  -webkit-text-stroke: 11px #fffaf0; paint-order: stroke fill; filter: drop-shadow(3px 5px 0 rgba(26,20,16,.45)); animation: slap .6s cubic-bezier(.2,1.4,.4,1) .5s both; --r: -4deg; }
.splash .tag { display: inline-block; margin: 0 0 22px; padding: 5px 14px; background: #fffaf0; color: var(--ink); border: 3px solid var(--ink); border-radius: 4px; font-size: 1.02rem; line-height: 1.25; transform: rotate(1.8deg); box-shadow: 3px 4px 0 rgba(26,20,16,.3); }
.splash .btn.primary { font: 400 1.5rem var(--font-marker); letter-spacing: .04em; padding: 10px 44px; background: var(--ochre); border: 4px solid var(--ink); border-radius: 12px; transform: rotate(-1.5deg);
  box-shadow: 0 0 0 5px #fffaf0, 0 0 0 7px rgba(26,20,16,.35), 5px 9px 0 7px rgba(26,20,16,.22); animation: pulse 1.8s ease-in-out infinite; }
.splash .btn.primary:disabled { animation: none; opacity: .85; }
.splash .btn.primary:active { transform: rotate(-1.5deg) translateY(2px); }
@keyframes pulse { 0%, 100% { scale: 1; } 50% { scale: 1.05; } }
.splash .fine { margin-top: 22px; display: inline-block; padding: 1px 10px; background: rgba(255,250,240,.85); border-radius: 8px; }
/* the face frame fades into the picture so there are no hard side bands */
.portrait-canvas { -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent); }

/* ---- first-time tour: a sticky note and pencilled arrows ---- */
.tut { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.tut-svg { position: absolute; inset: 0; overflow: visible; }
@keyframes tutDraw { to { stroke-dashoffset: 0; } }
.tut-note { position: absolute; box-sizing: border-box; pointer-events: auto; padding: 12px 13px 8px; background: #fff0a8; border: 3px solid var(--ink); border-radius: 3px 10px 4px 12px;
  box-shadow: 0 5px 0 rgba(26,20,16,.28), 0 14px 20px rgba(60,36,10,.22); transform: rotate(var(--tilt, -1.2deg)); animation: tutPop .38s cubic-bezier(.2,1.5,.4,1) both; }
.tut-note::before { content: ''; position: absolute; top: -12px; left: 50%; width: 56px; height: 18px; transform: translateX(-50%) rotate(-3deg); background: rgba(255,255,255,.6); border: 1.5px solid rgba(26,20,16,.22); }
.tut-note p { margin: 0 0 7px; font: 700 1rem/1.25 var(--font-hand); color: var(--ink); }
.tut-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tut-hint { font-size: .8rem; font-style: italic; color: var(--ink-soft); }
.tut-actions .linkbtn { font-size: .78rem; font-weight: 400; color: var(--ink-soft); }
@keyframes tutPop { from { opacity: 0; transform: rotate(var(--tilt, -1.2deg)) translateY(10px) scale(.86); } }
@media (prefers-reduced-motion: reduce) { .tut-svg path { animation: none !important; stroke-dashoffset: 0 !important; } .tut-note { animation: none; } }
