/*
 * Loaf and Order: every control is a sticker (ART.md §8): a rounded shape with a
 * 3 px ink border and a hard ink drop shadow; pressing pushes it down 3 px.
 */
:root {
  --ink: #3a2a3f;
  --cream: #fbf5ea;
  --wall: #f6ead6;
  --gold: #f2b93b;
  --oat: #e9d3a8;
  --red: #e2553f;
  --green: #6fbf73;
  --off: #d9d2c6;
  --sage: #8fb0a8;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --edge: 3px;
  --drop: 0 4px 0 var(--ink);
  --spring: cubic-bezier(.2, 1.5, .4, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--wall); color: var(--ink); font-family: var(--font); font-weight: 600; overscroll-behavior: none; font-variant-numeric: tabular-nums; }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
svg { width: 1em; height: 1em; display: block; overflow: visible; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
.layer { position: absolute; inset: 0; display: none; pointer-events: none; }
.layer.on { display: block; }
.layer.on > * { pointer-events: auto; }
.layer.on > .pops, .layer.on > .ghost, .layer.on > .eye, .layer.on > .tug { pointer-events: none; }

/* Stickers */
.round { width: 48px; height: 48px; border-radius: 50%; background: var(--cream); border: var(--edge) solid var(--ink); box-shadow: var(--drop); display: grid; place-items: center; transition: transform 120ms var(--spring), box-shadow 120ms; }
.round svg { width: 24px; height: 24px; }
.round.big { width: 64px; height: 64px; }
.round.big svg { width: 30px; height: 30px; }
.round.gold { background: var(--gold); }
.round:active, .round.down { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.round:disabled { background: var(--off); opacity: 0.7; }

/* ----------------------------------------------------------------- home */
#home { display: none; }
#home.on { display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(28px + var(--safe-t)) 16px calc(26px + var(--safe-b)); }
.logo { margin: 0; display: flex; align-items: center; font-size: clamp(46px, 14vw, 72px); font-weight: 800; letter-spacing: 0.01em; color: var(--cream); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); line-height: 1; pointer-events: none !important; }
.logo { flex-wrap: wrap; justify-content: center; }
.logo-sub { flex-basis: 100%; text-align: center; font-size: 0.6em; margin-top: 0.18em; }
.logo-face { width: 0.95em; height: 0.95em; margin: 0 0.02em; filter: drop-shadow(0 5px 0 var(--ink)); transform: translateY(0.04em); }
.home-bottom { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.days { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 100%; margin-top: auto; margin-bottom: 18px; }
.day { width: 44px; height: 56px; border-radius: 16px; background: var(--cream); border: var(--edge) solid var(--ink); box-shadow: var(--drop); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 800; font-size: 18px; transition: transform 120ms var(--spring), box-shadow 120ms; }
.day:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.day[aria-pressed="true"] { background: var(--gold); }
.day:disabled { background: var(--off); color: #8d8478; box-shadow: 0 2px 0 var(--ink); }
.day .st { display: flex; gap: 1px; color: #e7dcc8; }
.day .st svg { width: 10px; height: 10px; }
.day .st svg.on { color: var(--gold); }
.day[aria-pressed="true"] .st svg.on { color: #fff6d8; }
.play { width: 112px; height: 112px; border-radius: 50%; background: var(--gold); border: 4px solid var(--ink); box-shadow: 0 7px 0 var(--ink); display: grid; place-items: center; color: var(--cream); transition: transform 120ms var(--spring), box-shadow 120ms; animation: breathe 2.4s ease-in-out infinite; }
.play svg { width: 58px; height: 58px; }
.play:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--ink); animation: none; }
@keyframes breathe { 50% { transform: scale(1.05); } }
.home-row { display: flex; gap: 14px; margin-top: 18px; }

/* ------------------------------------------------------------------ HUD */
.hud-top { position: absolute; top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); display: flex; align-items: flex-start; gap: 10px; pointer-events: none !important; }
.hud-top > * { pointer-events: auto; }
.list { display: flex; flex-direction: column; gap: 6px; }
.chip { position: relative; display: flex; align-items: center; gap: 4px; height: 44px; padding: 0 9px 0 3px; border-radius: 22px; background: var(--cream); border: var(--edge) solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-weight: 800; font-size: 15px; width: max-content; transition: background 200ms; }
.chip .ic { position: relative; width: 34px; height: 34px; display: grid; place-items: center; }
.chip .ic svg.k { width: 22px; height: 22px; }
.chip .ic svg.pr { position: absolute; inset: 0; width: 34px; height: 34px; transform: rotate(-90deg); }
.chip .pr circle { fill: none; stroke-width: 3.5; }
.chip .pr .track { stroke: #eadfcb; }
.chip .pr .fill { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset 200ms; }
.chip .n { min-width: 2.2em; }
.chip.solo { padding-right: 3px; }
.chip.solo .n { display: none; }
.chip.done { background: #dff1d8; }
.chip .tick { position: absolute; left: 20px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--green); border: 2.5px solid var(--ink); color: #fff; display: none; place-items: center; }
.chip .tick svg { width: 13px; height: 13px; }
.chip.done .tick { display: grid; animation: stamp 0.45s var(--spring); }
.chip.bump { animation: chipBump 0.3s var(--spring); }
.chip.nap { background: var(--oat); animation: chipIn 0.4s var(--spring); }
@keyframes stamp { 0% { transform: scale(2.2) rotate(-20deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes chipBump { 40% { transform: scale(1.1); } }
@keyframes chipIn { 0% { transform: translateX(-40px); opacity: 0; } }
.hud-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding-top: 4px; }
.clock { width: 100%; max-width: 240px; height: 12px; border-radius: 6px; background: var(--cream); border: 2.5px solid var(--ink); overflow: hidden; }
.clock i { display: block; height: 100%; width: 100%; background: var(--sage); transform-origin: left; }
.clock.late i { background: var(--red); }
.tally { display: flex; align-items: center; gap: 6px; }
.tally b { font-weight: 800; font-size: 26px; color: var(--cream); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); }
.tally b.bump { animation: chipBump 0.25s var(--spring); }
.tally i { font-style: normal; font-weight: 800; font-size: 16px; background: var(--gold); border: 2.5px solid var(--ink); border-radius: 12px; padding: 1px 8px; box-shadow: 0 2px 0 var(--ink); }
.tally i.bump { animation: chipBump 0.3s var(--spring); }

.pops span { position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 20px; color: var(--gold); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; animation: popUp 0.9s ease-out forwards; white-space: nowrap; }
.pops span.big { font-size: 26px; }
@keyframes popUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }

/* Buttons for the thumb */
.loaf, .action { position: absolute; bottom: calc(22px + var(--safe-b)); border-radius: 50%; border: var(--edge) solid var(--ink); box-shadow: 0 5px 0 var(--ink); display: grid; place-items: center; transition: transform 100ms var(--spring), box-shadow 100ms, background 150ms; }
.loaf { left: calc(18px + var(--safe-l)); width: 88px; height: 88px; background: var(--oat); }
.loaf svg { width: 54px; height: 54px; }
.loaf.on { background: #fff; box-shadow: 0 5px 0 var(--ink), 0 0 0 8px rgba(255, 255, 255, 0.55), 0 0 26px 10px rgba(255, 255, 255, 0.6); }
.loaf.teach { animation: teach 0.7s ease-in-out infinite; }
@keyframes teach { 50% { transform: scale(1.14); box-shadow: 0 5px 0 var(--ink), 0 0 0 10px rgba(242, 185, 59, 0.6); } }
.action { right: calc(18px + var(--safe-r)); bottom: calc(34px + var(--safe-b)); width: 76px; height: 76px; background: var(--gold); }
.action .ic { width: 42px; height: 42px; position: relative; }
.action .ring { position: absolute; inset: -9px; width: calc(100% + 18px); height: calc(100% + 18px); transform: rotate(-90deg); pointer-events: none; }
.action .ring circle { fill: none; stroke: var(--green); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 226.2; stroke-dashoffset: 226.2; transition: stroke-dashoffset 120ms; filter: drop-shadow(0 0 1.5px var(--ink)); }
.action.none { background: var(--off); box-shadow: 0 3px 0 var(--ink); }
.action.none .ic { opacity: 0; }
.loaf.down, .action.down { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.action.wriggle { width: 96px; height: 96px; animation: teach 0.5s ease-in-out infinite; }
.action.pop .ic { animation: chipBump 0.3s var(--spring); }

/* Where the human is, when they are off screen */
.eye { position: absolute; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: var(--cream); border: var(--edge) solid var(--ink); box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; }
.eye .eye-ic { width: 26px; height: 26px; }
.eye .eye-ring { position: absolute; inset: -7px; width: 56px; height: 56px; transform: rotate(-90deg); }
.eye-ring circle { fill: none; stroke-width: 4.5; }
.eye-ring .track { stroke: transparent; }
.eye-ring .fill { stroke: var(--gold); stroke-dasharray: 106.8; stroke-dashoffset: 106.8; stroke-linecap: round; }
.eye.hot .eye-ring .fill { stroke: var(--red); }
.eye b { position: absolute; right: -8px; top: -10px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--gold); border: 2.5px solid var(--ink); font-weight: 800; font-size: 14px; line-height: 17px; text-align: center; display: none; }
.eye b.on { display: block; }
.eye.hot b { background: var(--red); color: #fff; }
.eye.blink .eye-ic { animation: blink 0.5s ease-in-out; }
@keyframes blink { 40%, 60% { transform: scaleY(0.1); } }

/* The hug: a tug of war between the human's heart and her paw */
.tug { position: absolute; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; width: min(300px, 76vw); }
.tug svg { width: 32px; height: 32px; flex: none; }
.tug-bar { position: relative; flex: 1; height: 18px; border-radius: 9px; background: var(--cream); border: var(--edge) solid var(--ink); box-shadow: 0 3px 0 var(--ink); overflow: hidden; }
.tug-bar i { position: absolute; top: 0; bottom: 0; width: 50%; transition: width 120ms; }
.tug-bar .purr { left: 0; background: #f0a3a8; }
.tug-bar .wriggle { right: 0; background: var(--gold); }

/* A ghost finger shows the stroke once */
.ghost { position: absolute; left: 0; right: 0; top: 66%; bottom: 140px; }
.ghost i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(255, 255, 255, 0.75); border: var(--edge) solid rgba(58, 42, 63, 0.55); box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.25); }
.ghost.lr i { animation: ghostLR 0.9s ease-in-out infinite; }
.ghost.d i { animation: ghostD 0.8s ease-in infinite; }
.ghost.press { left: auto; top: auto; right: calc(18px + var(--safe-r)); bottom: calc(34px + var(--safe-b)); width: 76px; height: 76px; }
.ghost.press i { left: 50%; top: 50%; animation: ghostPress 1.2s ease-in-out infinite; }
@keyframes ghostLR { 0%, 100% { transform: translateX(-70px); } 50% { transform: translateX(70px); } }
@keyframes ghostD { 0% { transform: translateY(-50px); opacity: 0; } 20% { opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(60px); opacity: 0; } }
@keyframes ghostPress { 0%, 100% { transform: translate(18px, 18px) scale(1); } 30%, 80% { transform: translate(4px, 4px) scale(0.82); } }

/* --------------------------------------------------------------- result */
#result.on { display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); background: rgba(246, 234, 214, 0.55); }
.res-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(420px, 100%); }
.polaroid { position: relative; margin: 0; width: 100%; background: #fff; padding: 14px 14px 0; border: var(--edge) solid var(--ink); box-shadow: 0 6px 0 var(--ink); transform: rotate(-3deg); animation: develop 0.7s var(--spring); }
@keyframes develop { 0% { transform: rotate(-12deg) scale(0.6); opacity: 0; } 100% { transform: rotate(-3deg); opacity: 1; } }
.polaroid img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; background: #e9dcc8; border: 2px solid var(--ink); }
.polaroid .tape { position: absolute; left: 50%; top: -14px; width: 96px; height: 26px; margin-left: -48px; background: rgba(143, 176, 168, 0.85); transform: rotate(4deg); border-left: 2px dashed rgba(255, 255, 255, 0.5); border-right: 2px dashed rgba(255, 255, 255, 0.5); }
.polaroid figcaption { height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 20px; }
.polaroid .stars { display: flex; gap: 3px; color: #ece3d3; }
.polaroid .stars svg { width: 26px; height: 26px; }
.polaroid .stars svg.on { color: var(--gold); animation: stamp 0.4s var(--spring) backwards; }
.polaroid figcaption b { font-size: 26px; min-width: 3ch; text-align: right; }
.tallies { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tallies li { display: flex; align-items: center; gap: 5px; height: 40px; padding: 0 12px 0 6px; border-radius: 20px; background: var(--cream); border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-weight: 800; font-size: 17px; }
.tallies svg { width: 24px; height: 24px; }
.res-buttons { display: flex; gap: 18px; }

/* ------------------------------------------------------------ menu, account */
.modal.on { display: flex; align-items: center; justify-content: center; background: rgba(58, 42, 63, 0.35); padding: 16px; pointer-events: auto; }
.card { background: var(--cream); border: var(--edge) solid var(--ink); border-radius: 18px; box-shadow: 0 6px 0 var(--ink); padding: 18px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0 0 4px; text-align: center; font-weight: 800; font-size: 26px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: #fff; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-weight: 700; font-size: 17px; text-align: left; }
.row svg { width: 22px; height: 22px; flex: none; }
.row span { flex: 1; min-width: 0; }
.row b { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.row:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.row.danger { color: var(--red); }
.cta { margin-top: 6px; padding: 13px; border-radius: 16px; background: var(--gold); border: var(--edge) solid var(--ink); box-shadow: var(--drop); font-weight: 800; font-size: 19px; }
.cta:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.build { margin: 4px 0 0; text-align: center; font-size: 12px; color: #8d8478; }
.acct-row { display: flex; gap: 8px; }
.acct-row input { flex: 1; min-width: 0; font: inherit; font-size: 17px; padding: 10px 12px; border-radius: 12px; border: 2.5px solid var(--ink); background: #fff; color: var(--ink); }
.chip-btn { padding: 0 14px; border-radius: 12px; background: var(--gold); border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-weight: 800; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.chip-btn:disabled { background: var(--off); }
.acct-note { margin: 0; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; }
.acct-links { display: flex; justify-content: space-between; margin-top: 4px; }
.link-btn { text-decoration: underline; font-size: 14px; color: #6d6170; }
.link-btn:disabled { opacity: 0.5; }
.acct-in span { display: flex; flex-direction: column; }
.acct-in small { font-weight: 600; color: #6d6170; }
.acct-error { margin: 0; color: var(--red); text-align: center; }
.acct-captcha:empty { display: none; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(1turn); } }

.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash 0.5s ease-out; }
@keyframes flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }

/* Landscape: list on the left, everything else stays put */
@media (min-aspect-ratio: 3/2) {
  .tug { bottom: calc(40px + var(--safe-b)); }
  .res-wrap { flex-direction: row; flex-wrap: wrap; justify-content: center; width: min(900px, 100%); }
  .polaroid { width: min(460px, 55vw); }
  .res-side { display: flex; flex-direction: column; gap: 18px; align-items: center; }
}
@media (prefers-reduced-motion: reduce) {
  .play, .loaf.teach, .action.wriggle { animation: none; }
}
