:root {
  --field: #ff2e88;
  --field-deep: #d9146b;
  --ink: #4a0623;
  --ink-soft: #7a1a45;
  --cream: #fff6ef;
  --white: #ffffff;
  --shadow: 0 10px 30px rgba(74, 6, 35, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--field);
  color: var(--cream);
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  padding: 0 0 calc(24px + env(safe-area-inset-bottom));
}
.board, .shelf-wrap, .end { margin-left: 16px; margin-right: 16px; }
@media (min-width: 792px) { .board, .end { margin-left: auto; margin-right: auto; } }
button { font: inherit; cursor: pointer; }
input { font: inherit; }
a { color: inherit; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 6px 12px; padding: 18px 16px 0; max-width: 992px; margin: 0 auto; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .08em; text-decoration: none; font-size: clamp(15px, 2.2vw, 20px); }
.waiting { font-size: clamp(13px, 1.8vw, 16px); opacity: .9; text-align: right; }

.stage { width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2vh 16px 24px; min-height: calc(100dvh - 58px); justify-content: center; }
.panel { max-width: 760px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }
.share { background: transparent; color: var(--cream); border: 3px solid rgba(255, 246, 239, .6); margin-top: 8px; }
.mallow-wrap { position: relative; width: clamp(240px, 46vmin, 460px); aspect-ratio: 1; margin-bottom: 8px; }
.mallow { width: 100%; height: 100%; display: block; object-fit: contain; transform-origin: 50% 85%; transform: scale(var(--grow, 1));
  animation: breathe 4.2s ease-in-out infinite; filter: drop-shadow(0 18px 24px rgba(74, 6, 35, .35)); user-select: none; -webkit-user-drag: none; }
@keyframes breathe { 0%, 100% { transform: scale(var(--grow, 1)) scaleY(1); } 50% { transform: scale(var(--grow, 1)) scaleY(.965) scaleX(1.02); } }
.mallow.pop { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) 1, breathe 4.2s ease-in-out .6s infinite; }
@keyframes pop { 0% { transform: scale(0); } 100% { transform: scale(var(--grow, 1)); } }
.mallow.gone { animation: chomp .7s ease-in forwards; }
@keyframes chomp { 0% { transform: scale(var(--grow, 1)); } 30% { transform: scale(var(--grow, 1)) rotate(-8deg); } 55% { transform: scale(calc(var(--grow, 1) * .6)) rotate(6deg); } 100% { transform: scale(0) rotate(0); opacity: 0; } }
.crumbs { position: absolute; inset: 0; pointer-events: none; }
.crumbs i { position: absolute; left: 50%; top: 60%; width: 10px; height: 10px; border-radius: 40% 60% 50% 50%; background: var(--white); opacity: 0; }
.crumbs.go i { animation: crumb .9s ease-out forwards; }
@keyframes crumb { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.4); } }

.panel { display: none; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
body[data-screen="fresh"] .panel.fresh, body[data-screen="holding"] .panel.holding, body[data-screen="done"] .panel.done { display: flex; }
body[data-screen="loading"] .mallow { visibility: hidden; }

h1 { font-size: clamp(30px, 6vw, 56px); font-weight: 700; margin: 0; line-height: 1.05; }
.lede { font-size: clamp(16px, 2.4vw, 22px); line-height: 1.35; margin: 0 0 10px; opacity: .95; }
.day { font-size: clamp(22px, 4vw, 34px); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.score { font-size: clamp(44px, 12vw, 128px); font-weight: 700; line-height: 1; letter-spacing: -.02em; color: var(--white); text-shadow: 0 6px 0 rgba(74, 6, 35, .25); word-break: break-all; max-width: 100%; }
.score.long { font-size: clamp(26px, 6vw, 56px); }
.score.huge { font-size: clamp(18px, 3.4vw, 30px); letter-spacing: 0; }
.next { font-size: clamp(16px, 2.4vw, 22px); }
.next b { font-variant-numeric: tabular-nums; }

.btn { border: 0; border-radius: 999px; padding: 16px 40px; font-size: clamp(18px, 2.6vw, 24px); font-weight: 700; letter-spacing: .02em; transition: transform .12s ease, box-shadow .12s ease; }
.btn:active { transform: translateY(2px); }
.btn:focus-visible { outline: 4px solid var(--white); outline-offset: 3px; }
.primary { background: var(--white); color: var(--ink); box-shadow: var(--shadow); margin-top: 8px; }
.primary:hover { transform: translateY(-2px); }
.eat { background: transparent; color: var(--cream); border: 3px solid rgba(255, 246, 239, .6); margin-top: 18px; padding: 12px 30px; font-size: clamp(16px, 2.2vw, 20px); }
.eat:hover { background: rgba(74, 6, 35, .25); border-color: var(--cream); }
.ink { background: var(--ink); color: var(--cream); }
.ghost { background: transparent; color: var(--ink); text-decoration: underline; padding-left: 16px; padding-right: 16px; }
.link { margin-top: 14px; font-size: 14px; opacity: .85; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; align-items: center; }
.copy { background: none; border: 0; color: var(--cream); text-decoration: underline; padding: 4px; }

.board { max-width: 760px; margin: 12px auto 0; background: var(--ink); color: var(--cream); border-radius: 22px; padding: 22px clamp(14px, 3vw, 28px) 18px; box-shadow: var(--shadow); }
.board h2 { margin: 0; font-size: clamp(20px, 3vw, 28px); letter-spacing: .1em; }
.board-sub { margin: 4px 0 14px; opacity: .8; font-size: 15px; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rows li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; padding: 10px 12px; border-radius: 12px; background: rgba(255, 246, 239, .06); }
.rows li.me { background: var(--field); color: var(--white); }
.rows .n { opacity: .6; font-variant-numeric: tabular-nums; }
.rows .who { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.rows .msg { grid-column: 2 / 4; opacity: .85; font-weight: 400; overflow-wrap: anywhere; }
.rows .pts { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.rows .pts small { display: block; font-weight: 400; opacity: .7; font-size: 12px; }
.empty { opacity: .75; }

.sheet { position: fixed; inset: 0; background: rgba(74, 6, 35, .55); display: grid; place-items: center; padding: 16px; z-index: 10; }
.sheet[hidden] { display: none; }
.card { background: var(--cream); color: var(--ink); border-radius: 22px; padding: 26px 24px; width: min(460px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0; font-size: 30px; }
.warn { margin: 0; line-height: 1.4; font-size: 17px; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.card input { border: 2px solid var(--ink-soft); border-radius: 12px; padding: 12px 14px; font-size: 17px; background: var(--white); color: var(--ink); }
.card input:focus { outline: 3px solid var(--field); outline-offset: 1px; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.actions .btn { padding: 12px 26px; font-size: 18px; }

.end { max-width: 760px; margin: 18px auto 0; }
.end:empty { display: none; }
.shelf-wrap { max-width: 960px; margin: 18px auto 0; zoom: .78; }
@media (min-width: 760px) { .shelf-wrap { zoom: .58; } }
.foot { text-align: center; font-size: 13px; opacity: .7; margin-top: 18px; }

@media (prefers-reduced-motion: reduce) { .mallow, .mallow.pop { animation: none; } }

/* After eating: the marshmallow is gone, a few crumbs stay on the field. */
body[data-screen="done"] .mallow { visibility: hidden; }
body[data-screen="done"] .mallow-wrap { height: clamp(120px, 20vmin, 220px); }
body[data-screen="done"] .crumbs i { animation: none; opacity: .9; transform: translate(var(--dx), var(--dy)) scale(.6); }
body[data-screen="done"] .crumbs:empty::before, body[data-screen="done"] .crumbs:empty::after { content: ""; position: absolute; left: 46%; top: 55%; width: 12px; height: 9px; border-radius: 50%; background: var(--white); opacity: .9; box-shadow: 40px 18px 0 -2px var(--white), -36px 26px 0 -3px var(--white), 10px 40px 0 -4px var(--white), -60px 2px 0 -4px var(--white); }
/* After eating, the end panel carries the shelf; the door's own shelf steps aside. */
body[data-screen="done"] .shelf-wrap { display: none; }
.end { zoom: .8; }
@media (min-width: 760px) { .end { zoom: .6; } }
