:root {
  color-scheme: light;
  --paper: #f7eedd; --paper-deep: #efe2c8; --sheet: #fffdf8;
  --ink: #2c3a29; --ink-soft: #5a5a44; --moss: #47603f; --moss-deep: #364b30;
  --rule: #d3c4a3; --coral: #a93f38; --speck: rgba(122, 92, 44, .04);
  --serif: "Iowan Old Style", "New York", ui-serif, Palatino, "Palatino Linotype", Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); font: 16px/1.35 var(--serif); overflow: hidden;
  background-color: var(--paper);
  background-image: radial-gradient(var(--speck) .7px, transparent 1.1px), radial-gradient(var(--speck) .6px, transparent 1px), radial-gradient(ellipse at 20% 0%, rgba(255,250,235,.9), transparent 60%);
  background-size: 7px 11px, 13px 5px, 100% 100%; background-position: 0 0, 3px 4px, 0 0;
}
h1, h2, p, ol { margin: 0; padding: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--moss-deep); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }

.app { height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px 2px; }
.wordmark { font-size: 20px; font-weight: 500; letter-spacing: -.008em; color: var(--moss-deep); }
.actions { display: flex; gap: 6px; }
.ghost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 12px; background: transparent; border: 1px solid var(--rule); border-radius: 4px; color: var(--moss-deep); font-style: italic; }
.ghost svg { width: 20px; height: 20px; }
.ghost:hover { background: var(--paper-deep); }
.ghost[aria-pressed="true"] { background: var(--moss); border-color: var(--moss); color: var(--sheet); }
.round { padding: 0; font-style: normal; font-size: 19px; }

.picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 4px 12px 6px; border-bottom: 1px solid var(--rule); }
.picker button { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 48px; padding: 2px 0 4px; background: transparent; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--ink-soft); }
.picker b { font-weight: 500; font-size: 17px; }
.picker small { font-size: 12.5px; font-style: italic; min-height: 16px; }
.picker [aria-current="true"] { color: var(--moss-deep); border-bottom-color: var(--moss); }

.stage { position: relative; min-height: 0; margin: 0 8px; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: grab; }
#board.panning { cursor: grabbing; }
.meter { position: absolute; left: 12px; right: 12px; bottom: 2px; height: 3px; background: rgba(211,196,163,.55); border-radius: 2px; overflow: hidden; pointer-events: none; }
.meter i { display: block; height: 100%; width: 0; background: var(--moss); transition: width .3s; }
.fit { position: absolute; right: 8px; top: 8px; min-width: 44px; min-height: 44px; padding: 0 10px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; color: var(--moss-deep); font-style: italic; box-shadow: 0 2px 6px rgba(70,50,20,.15); }
.pill { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); padding: 6px 12px; background: var(--moss-deep); color: var(--sheet); border-radius: 4px; font-size: 15px; font-style: italic; white-space: nowrap; pointer-events: none; }
.toast { position: absolute; left: 50%; bottom: 14px; transform: translate(-50%, 8px); padding: 7px 14px; background: rgba(255,253,248,.97); border: 1px solid var(--rule); border-radius: 4px; color: var(--coral); font-style: italic; box-shadow: 0 3px 10px rgba(70,50,20,.18); opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.tray { padding: 4px 10px 8px; }
.status { text-align: center; font-size: 15px; font-style: italic; color: var(--ink-soft); min-height: 20px; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 2px; margin-top: 2px; max-height: 34dvh; overflow-y: auto; }
.swatch { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; padding: 2px 0; background: transparent; border: 0; border-radius: 6px; }
.blob { position: relative; display: flex; align-items: center; justify-content: center; width: 40px; height: 36px; border-radius: 47% 53% 50% 50% / 55% 48% 52% 45%; box-shadow: inset 0 0 0 1px rgba(60,45,20,.22), inset 0 -3px 6px rgba(60,40,10,.10); font-size: 18px; font-weight: 600; transition: transform .14s; }
.swatch small { font-size: 12.5px; line-height: 1.1; color: var(--ink-soft); font-variant-numeric: tabular-nums; margin-top: 1px; }
.swatch[aria-pressed="true"] { background: var(--paper-deep); box-shadow: inset 0 0 0 2px var(--moss); }
.swatch[aria-pressed="true"] .blob { transform: scale(1.07); }
.swatch.finished .blob { background: var(--paper-deep) !important; color: var(--moss) !important; box-shadow: inset 0 0 0 1px var(--rule); }
.swatch.finished small { visibility: hidden; }
.swatch.finished { cursor: default; }
.swatch.nudge .blob { animation: nudge .55s ease; }
@keyframes nudge { 30% { transform: scale(1.18); } 70% { transform: scale(.97); } }

.done { padding: 8px 6px 10px; text-align: center; }
.done h2 { font-size: 27px; font-weight: 500; color: var(--moss-deep); }
.done p { margin-top: 2px; font-style: italic; color: var(--ink-soft); }
.done-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.go { min-height: 48px; padding: 0 20px; background: var(--moss); color: var(--sheet); border: 0; border-radius: 4px; }
.go:hover { background: var(--moss-deep); }

.scrim { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(62,50,30,.42); }
.howcard { width: min(100%, 340px); padding: 18px 18px 16px; background: var(--sheet); border-radius: 6px; box-shadow: 0 12px 34px rgba(50,35,10,.3); }
.howcard h2 { font-size: 21px; font-weight: 500; line-height: 1.15; color: var(--moss-deep); text-align: center; }
.demo { display: block; width: 100%; margin: 10px 0 8px; background: var(--paper); border-radius: 4px; }
.steps { padding-left: 1.3em; font-size: 15.5px; color: var(--ink-soft); }
.steps li + li { margin-top: 2px; }
.shape path { fill: var(--sheet); stroke: #33373a; stroke-width: 2.5; stroke-linejoin: round; }
.shape text { fill: #5a5a44; }
.chip text { font-weight: 600; fill: #33373a; }
.finger { fill: rgba(44,58,41,.35); stroke: rgba(255,253,248,.9); stroke-width: 2; }
.demo .chip1-ring { }
.play #sA path { animation: fillA 7.4s linear forwards; }
.play #sC path { animation: fillC 7.4s linear forwards; }
.play #sA text { animation: hideA 7.4s linear forwards; }
.play #sC text { animation: hideC 7.4s linear forwards; }
.play #chip1 circle { animation: ring 7.4s linear forwards; }
.play #finger { animation: fingerMove 7.4s ease-in-out forwards; }
@keyframes fingerMove {
  0% { transform: translate(250px,180px); opacity: 0; }
  6% { transform: translate(250px,180px); opacity: 1; }
  18%, 24% { transform: translate(118px,146px); }
  48%, 54% { transform: translate(62px,58px); }
  76%, 82% { transform: translate(237px,58px); opacity: 1; }
  92%, 100% { transform: translate(237px,160px); opacity: 0; }
}
@keyframes ring { 0%, 21% { stroke: none; stroke-width: 0; } 22%, 86% { stroke: #47603f; stroke-width: 3.5; } 88%, 100% { stroke: none; } }
@keyframes fillA { 0%, 24% { fill: #fffdf8; } 25%, 49% { fill: url(#stripe); } 52%, 100% { fill: #e7a93f; } }
@keyframes fillC { 0%, 24% { fill: #fffdf8; } 25%, 77% { fill: url(#stripe); } 80%, 100% { fill: #e7a93f; } }
@keyframes hideA { 0%, 50% { opacity: 1; } 52%, 100% { opacity: 0; } }
@keyframes hideC { 0%, 78% { opacity: 1; } 80%, 100% { opacity: 0; } }

@media (min-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr) 372px; grid-template-rows: auto auto minmax(0, 1fr); column-gap: 20px; padding: 14px 24px 14px 16px; }
  .stage { grid-column: 1; grid-row: 1 / -1; margin: 0; }
  .top { grid-column: 2; padding: 0; }
  .wordmark { font-size: 27px; }
  .picker { grid-column: 2; margin: 10px 0 8px; }
  .tray { grid-column: 2; display: flex; flex-direction: column; min-height: 0; padding: 4px 0 0; }
  .palette { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; max-height: none; overflow-y: auto; margin-top: 8px; }
  .swatch { min-height: 72px; }
  .blob { width: 48px; height: 44px; font-size: 21px; }
  .status { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .swatch[aria-pressed="true"] .blob { transform: none; }
}
.demo.still #sA path, .demo.still #sC path { fill: #e7a93f; }
.demo.still #sA text, .demo.still #sC text { opacity: 0; }
.demo.still #finger { transform: translate(237px,58px); }
