/* picotop: see ../DESIGN.md */
:root {
  --ground: #ffffff;
  --raised: #f4f5f7;
  --hair: #e6e8eb;
  --ink: #0e1116;
  --muted: #6b7280;
  --up: #0cb84a;
  --down: #f0442c;
  --gold: #e9a800;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #000000; --raised: #111214; --hair: #23252a; --ink: #f5f6f7; --muted: #8b9099;
    --up: #21ce5c; --down: #ff5a3c; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #000000; --raised: #111214; --hair: #23252a; --ink: #f5f6f7; --muted: #8b9099;
  --up: #21ce5c; --down: #ff5a3c; color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ground); color: var(--ink); font: 16px/1.4 var(--font);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
  min-height: 100dvh; display: flex; flex-direction: column; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* header */
.bar > * { grid-row: 1; }
.bar {
  height: 52px; display: grid; grid-template-columns: 44px 1fr auto 44px 44px; align-items: center;
  padding: 0 6px; border-bottom: 1px solid var(--hair); position: sticky; top: 0; background: var(--ground); z-index: 3;
}
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--ink); }
.iconbtn:active { background: var(--raised); }
#mute { grid-column: 4; color: var(--muted); }
#theme { grid-column: 5; color: var(--muted); }
[data-theme="dark"] #theme .moon, :root:not([data-theme="dark"]) #theme .sun { display: none; }
#mute[aria-pressed="true"] .slash, #mute[aria-pressed="false"] .waves { display: none; }
.brand { grid-column: 1 / 3; display: flex; align-items: center; gap: 8px; padding-left: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand img { border-radius: 6px; }
body.in-game .brand { grid-column: 2; padding-left: 0; }
body:not(.in-game) .brand { visibility: hidden; }
.status { grid-column: 3; justify-self: end; padding-right: 4px; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.steps { display: flex; gap: 4px; }
.steps i { width: 18px; height: 4px; border-radius: 2px; background: var(--hair); }
.steps i.done { background: var(--ink); }
.lives { display: flex; gap: 3px; color: var(--down); }
.lives svg.lost { color: var(--hair); }

main { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 480px; margin: 0 auto; }

/* home */
.home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 16px 12vh; }
.home-icon { border-radius: 16px; margin-bottom: 18px; box-shadow: 0 0 0 1px var(--hair); }
.home h1 { font-size: 36px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.lede { margin: 10px 0 28px; font-size: 19px; line-height: 1.35; color: var(--ink); max-width: 28ch; text-wrap: balance; }
.home-actions { display: flex; flex-direction: column; gap: 10px; width: min(100%, 280px); }
.edition { margin-top: 28px; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.edition span { color: var(--muted); }
.progress { margin-top: 18px; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.home-done { width: min(100%, 280px); margin-bottom: 10px; }
.home-done .squares { font-size: 28px; letter-spacing: 6px; margin-bottom: 6px; }
.home-done p { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

/* pills */
.pill { height: 48px; padding: 0 22px; border-radius: 999px; font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s var(--ease), opacity .2s; text-decoration: none; white-space: nowrap; }
.pill:active:not(:disabled) { transform: scale(.97); }
.pill.ink { background: var(--ink); color: var(--ground); }
.pill.line { box-shadow: inset 0 0 0 1.5px var(--ink); color: var(--ink); }
.pill:disabled { cursor: default; }
.home .pill:disabled { opacity: .4; }
.pill.wide { width: 100%; }

/* play */
.play { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.quote { padding: 18px 16px 4px; }
.quote-meta { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); min-height: 24px; }
.quote-meta .dot { opacity: .6; }
.coin { width: 22px; height: 22px; border-radius: 50%; background: var(--raised); box-shadow: inset 0 0 0 1px var(--hair); flex: none; background-size: cover; display: grid; place-items: center; font-size: 12px; color: var(--muted); }
.coin.mystery::after { content: "?"; font-weight: 700; }
#ticker { color: var(--ink); }
.pnl { font-size: 52px; line-height: 1.02; font-weight: 600; letter-spacing: -0.03em; margin-top: 6px; }
.sub { font-size: 15px; font-weight: 600; min-height: 1.4em; margin-top: 4px; transition: color .2s; }
.sub.up { color: var(--up); } .sub.down { color: var(--down); } .sub.muted { color: var(--muted); }

.chart { position: relative; flex: 1; min-height: 180px; max-height: 46vh; margin: 8px 0 0; touch-action: pan-y; }
body.scrubbing .chart { touch-action: none; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }

.dock { padding: 12px 16px calc(18px + env(safe-area-inset-bottom)); min-height: 120px; }
.sell { width: 100%; height: 56px; font-size: 18px; }
.sell.counting { background: var(--raised); color: var(--muted); }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
@media (hover: none) { .hint { display: none; } }

/* X faces on the crowd strip */
.faces { position: absolute; inset: 0; pointer-events: none; }
.face { position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%; pointer-events: auto; box-shadow: 0 0 0 2px var(--ground); }
.face img { width: 20px; height: 20px; border-radius: 50%; display: block; object-fit: cover; }
.face.me { box-shadow: 0 0 0 2px var(--ink); z-index: 2; }
.face:hover { z-index: 3; }
.face::after { content: attr(data-h); position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--ground); font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 999px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; }
.face:hover::after, .face:focus-visible::after { opacity: 1; }

/* round result (in the dock) */
.result { animation: rise .26s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.verdict { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.verdict.pico { color: var(--gold); }
.why { color: var(--muted); font-size: 15px; margin-top: 2px; text-wrap: pretty; }
.score { text-align: right; flex: none; }
.score b { display: block; font-size: 34px; line-height: 1; font-weight: 700; letter-spacing: -0.02em; }
.score span { font-size: 12px; color: var(--muted); font-weight: 500; }
.facts { display: flex; gap: 6px; margin: 14px 0 16px; flex-wrap: wrap; }
.facts span { background: var(--raised); border-radius: 999px; padding: 6px 11px; font-size: 13px; font-weight: 600; }
.facts em { font-style: normal; color: var(--muted); font-weight: 500; margin-right: 4px; }
.lose { color: var(--down); font-weight: 600; }
.cta { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; padding: 6px; }
.cta svg { opacity: .6; }
.result-links { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.result-links .cta { margin-top: 0; }
.card-preview { width: 100%; height: auto; aspect-ratio: 1200 / 630; border-radius: 12px; box-shadow: 0 0 0 1px var(--hair); background: var(--raised); margin-bottom: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cta:hover { text-decoration: underline; text-underline-offset: 3px; }

/* summary */
.summary { flex: 1; padding: 28px 16px calc(24px + env(safe-area-inset-bottom)); animation: rise .26s var(--ease) both; }
.summary .kicker { font-size: 14px; font-weight: 600; color: var(--muted); }
.summary h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.summary .squares { font-size: 34px; letter-spacing: 8px; margin: 14px 0 6px; }
.beat { font-size: 17px; font-weight: 500; margin-top: 2px; }
.beat b { font-weight: 700; }
#run-pct { font-size: 17px; color: var(--ink); margin: -8px 0 0; }
#run-pct b { font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0 24px; text-align: center; }
.stats b { display: block; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.stats span { font-size: 12px; color: var(--muted); line-height: 1.2; display: block; margin-top: 2px; }
.dist h3 { font-size: 13px; font-weight: 700; text-transform: none; margin-bottom: 10px; }
.dist-row { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.dist-row i { display: block; height: 18px; border-radius: 4px; background: var(--hair); min-width: 4px; }
.dist-row.me i { background: var(--ink); }
.dist-row.me { color: var(--ink); font-weight: 600; }
.dist .empty { color: var(--muted); font-size: 14px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
@media (hover: none) { .desk { display: none !important; } }
.next-in { text-align: center; color: var(--muted); font-size: 14px; margin-top: 16px; }

/* home rows */
.home-rows { width: min(100%, 340px); margin-top: 26px; border-top: 1px solid var(--hair); }
.row-link { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--hair); text-align: left; }
.row-link:active { background: var(--raised); }
.row-icon { font-size: 24px; width: 32px; text-align: center; }
.row-main { flex: 1; display: flex; flex-direction: column; }
.row-main b { font-size: 16px; font-weight: 600; }
.row-main span { font-size: 13px; color: var(--muted); }
.chev { color: var(--muted); font-size: 22px; }

/* result extras */
.crowd { font-size: 14px; margin-top: 8px; min-height: 1.4em; }
.crowd b { font-weight: 700; }
.facts .xp { background: var(--ink); color: var(--ground); }
.facts .new { background: var(--gold); color: #1a1300; }

/* league */
.ladder { display: flex; gap: 6px; margin: 10px 0 12px; font-size: 22px; }
.ladder span { opacity: .25; filter: grayscale(1); }
.ladder span.past { opacity: .6; filter: none; }
.ladder span.on { opacity: 1; filter: none; transform: scale(1.25); }
.ltable { margin: 18px 0 8px; border-top: 1px solid var(--hair); }
.lrow { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--hair); font-size: 15px; }
.lrow.me { background: var(--raised); font-weight: 700; }
.lrank { color: var(--muted); font-weight: 600; }
.lxp { font-weight: 600; }
.zone { font-size: 12px; font-weight: 700; padding: 6px 4px; }
.zone.up { color: var(--up); } .zone.down { color: var(--down); }
.ltable .empty { color: var(--muted); font-size: 14px; padding: 14px 4px; }

/* account */
.avatar { width: 22px; height: 22px; border-radius: 50%; vertical-align: -5px; margin-right: 8px; object-fit: cover; }
.row-icon .avatar { width: 28px; height: 28px; margin: 0; vertical-align: middle; }
.avatar.big { width: 64px; height: 64px; margin: 0; }
.check { color: #1d9bf0; font-weight: 700; }
.who { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.who h2 { margin: 0; }
.who .why { margin: 0; }
.stats.two-rows { row-gap: 18px; }

.unclaimed { color: var(--muted); font-style: italic; }
.lrow.me .unclaimed { color: var(--ink); }
.board { margin: 6px 0 22px; }
.board h3 { font-size: 13px; font-weight: 700; }
.board .ltable { margin-top: 8px; }
.claim { margin-top: 14px; }
.center { text-align: center; }
.inline-claim { color: var(--ink); font-weight: 700; text-underline-offset: 3px; }

/* PnL */
.lpnl { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.lpnl b { font-weight: 700; font-size: 15px; }
.lpnl small { font-size: 12px; font-weight: 600; opacity: .75; }
.lrow { grid-template-columns: 34px 1fr auto; }
.hero-pnl { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin-top: 8px; }
.hero-pct { font-size: 17px; font-weight: 600; margin: 2px 0 6px; }
.tabs { display: inline-flex; gap: 4px; background: var(--raised); border-radius: 999px; padding: 4px; margin: 12px 0 4px; }
.tabs button { height: 34px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--muted); }
.tabs button.on { background: var(--ground); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* collection */
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; margin: 20px 0 24px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; border-radius: 14px; background: var(--raised); font-size: 12px; font-weight: 600; }
.tile img { border-radius: 50%; }
.tile em { font-style: normal; color: var(--muted); font-weight: 500; font-size: 11px; }
.tile.locked { color: var(--muted); opacity: .55; }
.tile.pico img, .tile.pico .coin-big { box-shadow: 0 0 0 3px var(--gold); }
.coin-big { width: 44px; height: 44px; border-radius: 50%; background: var(--hair); display: grid; place-items: center; font-weight: 700; font-size: 18px; color: var(--muted); }

/* privacy page + footer */
.legal { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; font-size: 16px; line-height: 1.55; }
.legal .brand { padding: 0; margin-bottom: 28px; }
.legal h1 { font-size: 28px; letter-spacing: -0.02em; margin-bottom: 14px; }
.legal p { margin-bottom: 14px; color: var(--ink); }
.legal a { color: var(--ink); }
.foot { margin-top: 22px; font-size: 12px; color: var(--muted); }
.foot a { color: var(--muted); }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }
@media (prefers-reduced-motion: reduce) { .result, .summary { animation: none; } }

@media (max-height: 640px) {
  .pnl { font-size: 44px; } .quote { padding-top: 12px; } .facts { margin: 10px 0 12px; }
  .home { padding-bottom: 6vh; } .home-icon { width: 56px; height: 56px; }
}
