@font-face { font-family: 'Luckiest Guy'; src: url(/fonts/luckiest-guy-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Rubik'; font-weight: 400; src: url(/fonts/rubik-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Rubik'; font-weight: 600; src: url(/fonts/rubik-latin-600-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Rubik'; font-weight: 800; src: url(/fonts/rubik-latin-800-normal.woff2) format('woff2'); font-display: swap; }

/* Snack Drawer palette: biscuit paper, chocolate ink, raspberry and mint. */
:root {
  --bg: #fff1dc; --paper: #fffdf8; --ink: #3a2418; --muted: #8a7263; --line: #ecd5b5;
  --aqua: #19a89a; --aqua-dark: #0c6f66; --orange: #ee4f7e; --orange-dark: #a8244d;
  --green: #23b67f; --red: #f0524f; --yellow: #ffd23f; --wood: #c98b4f; --wood-dark: #8c5a2b; --felt: #f6dfbf;
  --display: 'Luckiest Guy', 'Arial Black', Impact, sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--ink); font: 16px/1.45 var(--body); overscroll-behavior: none; background: var(--bg);
  background-image: radial-gradient(circle at 14px 14px, rgba(238, 79, 126, .13) 4px, transparent 5px); background-size: 34px 34px;
}
#app { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px)); }
.screen { width: min(540px, 100%); min-width: 0; max-width: 100%; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.screen > *, .card > * { min-width: 0; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; user-select: none; }
p { margin: 0; } .muted { color: var(--muted); } .center { text-align: center; }
a { color: var(--aqua-dark); }
:focus-visible { outline: 3px solid var(--aqua-dark); outline-offset: 2px; }

.bar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.bar .sp { flex: 1; }
.logo { font: 24px/1 var(--display); color: var(--wood-dark); letter-spacing: .4px; padding-top: 4px; text-decoration: none; white-space: nowrap; }
.logo span { color: var(--orange); }
.chip { border: 2px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; min-height: 36px; display: inline-flex; align-items: center; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); font-size: 18px; font-weight: 800; display: grid; place-items: center; flex: none; }

.card { background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; padding: 18px; box-shadow: 0 6px 0 rgba(58, 36, 24, .2); }
h1 { font: 40px/1 var(--display); margin: 2px 0 0; text-align: center; letter-spacing: .5px; }
h1 em { font-style: normal; color: var(--orange); }
h2 { font: 26px/1.08 var(--display); margin: 0; letter-spacing: .3px; }
.btn { border: 3px solid var(--ink); border-radius: 16px; padding: 14px 18px 10px; font: 22px/1 var(--display); letter-spacing: .5px; background: var(--paper); box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s; width: 100%; min-height: 48px; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.blue { background: var(--aqua); color: #fff; } .btn.orange { background: var(--orange); color: #fff; } .btn.yellow { background: var(--yellow); }
.btn.big { font-size: 28px; padding: 18px 18px 13px; }
.btn.small { font-size: 17px; padding: 12px 14px 8px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; min-width: 0; }
.hero { width: min(100%, 420px); aspect-ratio: 16 / 9; object-fit: cover; border-radius: 20px; border: 3px solid var(--ink); margin: 0 auto; display: block; box-shadow: 0 6px 0 rgba(58, 36, 24, .2); }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 600; padding: 10px 16px; border-radius: 999px; z-index: 9; max-width: calc(100vw - 28px); }
dialog { border: 3px solid var(--ink); border-radius: 22px; background: var(--paper); color: var(--ink); padding: 22px 20px 18px; width: min(460px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); overflow: auto; }
dialog::backdrop { background: rgba(58, 36, 24, .55); }
dialog ol, dialog ul { margin: 8px 0 14px; padding-left: 22px; } dialog li { margin: 5px 0; }
.acct { text-align: center; font-size: 14px; font-weight: 600; color: var(--muted); min-height: 21px; }

/* home */
.today { display: flex; align-items: center; gap: 12px; }
.today > div { flex: 1; min-width: 0; }
.mascot { width: 92px; height: 92px; object-fit: contain; flex: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--bg); border-radius: 14px; padding: 8px 6px; text-align: center; }
.stat small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.stat b { font: 22px/1.1 var(--display); display: block; padding-top: 3px; }

/* stars: a picture when we have one, a drawn star when we do not */
.stars { display: inline-flex; gap: 2px; justify-content: center; line-height: 1; }
.star { width: 1em; height: 1em; display: inline-grid; place-items: center; font-size: inherit; color: #d9c7ad; }
.star::before { content: '\2605'; }
.star.on { color: #f5a800; text-shadow: 0 1px 0 var(--ink); }
body.has-star .star.on { background: url(/img/star.webp) center / contain no-repeat; }
body.has-star .star.on::before { visibility: hidden; }

/* level map: a path that snakes down the page */
.map { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 8px; padding: 6px 2px 20px; }
.lv { border: 3px solid var(--ink); border-radius: 18px; background: var(--paper); aspect-ratio: 1 / 1.08; min-height: 56px; padding: 6px 2px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; box-shadow: 0 4px 0 var(--ink); position: relative; }
.lv b { font: 21px/1 var(--display); padding-top: 3px; }
.lv .stars { font-size: 13px; }
.lv.done { background: #fff6c9; }
.lv.now { background: var(--orange); color: #fff; animation: bob 1.3s ease-in-out infinite; }
.lv.now .star { color: rgba(255, 255, 255, .45); }
.lv.new { background: #dff7f3; }
.lv[disabled] { opacity: .5; box-shadow: none; cursor: default; background: var(--felt); }
.lv .dot { position: absolute; top: -9px; right: -5px; background: var(--aqua); color: #fff; font-size: 10px; font-weight: 800; border-radius: 999px; border: 2px solid var(--ink); padding: 1px 5px; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* the heads-up card above the drawer */
.hud { padding: 10px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.hud .lvl small, .hud .mv small { display: block; font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.hud .lvl b { font: 26px/1 var(--display); display: block; padding-top: 3px; }
.hud .mv { text-align: center; background: var(--bg); border-radius: 14px; padding: 6px 10px 3px; min-width: 62px; }
.hud .mv b { font: 30px/1 var(--display); display: block; padding-top: 3px; color: var(--orange-dark); }
.hud .mv.low b { color: var(--red); animation: bob .7s ease-in-out infinite; }
.goals { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.goal { display: inline-flex; align-items: center; gap: 5px; border: 2px solid var(--line); border-radius: 999px; padding: 3px 9px 3px 4px; font-weight: 800; font-size: 15px; background: #fff; min-height: 34px; }
.goal .ico { width: 26px; height: 26px; flex: none; position: relative; }
.goal.done { background: #d5f5e7; border-color: var(--green); }
.goal.done .n::before { content: '\2713'; color: var(--green); }
.goal.done .n span { display: none; }
.goal.score { padding-left: 10px; }
.status { text-align: center; font-weight: 800; min-height: 24px; font-size: 15px; }
.status.pop { animation: statuspop .35s cubic-bezier(.3, 1.6, .5, 1); color: var(--orange-dark); }
@keyframes statuspop { 0% { transform: scale(.6); opacity: 0; } }

/* the drawer */
.drawer { background: var(--wood); border: 3px solid var(--ink); border-radius: 22px; padding: 8px; box-shadow: 0 6px 0 rgba(58, 36, 24, .2), inset 0 0 0 3px rgba(255, 255, 255, .18); }
.board { position: relative; width: min(100%, calc((100dvh - 300px) * var(--C) / var(--R))); min-width: min(100%, 240px); aspect-ratio: var(--C) / var(--R); margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; border-radius: 12px; container-type: inline-size; }
.tiles { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--C), minmax(0, 1fr)); grid-template-rows: repeat(var(--R), minmax(0, 1fr)); }
.tile { background: var(--felt); box-shadow: inset 0 0 0 1px rgba(140, 90, 43, .22); }
.tile.hole { background: var(--wood-dark); box-shadow: inset 0 3px 6px rgba(0, 0, 0, .35); opacity: .55; }
.tile.jelly { background: #ffb3cf; box-shadow: inset 0 0 0 3px #ff6fa3, inset 0 0 0 1px rgba(140, 90, 43, .22); background-image: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, .8) 0 9%, transparent 10%), radial-gradient(circle at 68% 70%, rgba(255, 255, 255, .5) 0 6%, transparent 7%); }
body.has-jelly .tile.jelly { background: var(--felt) url(/img/jelly.webp) center / 104% no-repeat; box-shadow: inset 0 0 0 2px #ff6fa3; }
.pieces { position: absolute; inset: 0; }
.pc { position: absolute; left: 0; top: 0; width: calc(100% / var(--C)); height: calc(100% / var(--R)); padding: 0; border: 0; background: none; display: grid; place-items: center; transition: transform .17s ease-out; will-change: transform; touch-action: none; }
.board[data-step='fall'] .pc { transition: transform .28s cubic-bezier(.35, 1.25, .6, 1); }
.board[data-step='shuffle'] .pc { transition: transform .4s ease-in-out; }
.pc:focus-visible { outline: none; }
.pc:focus-visible .face { box-shadow: 0 0 0 3px var(--aqua-dark); }
.face { width: 84%; height: 84%; position: relative; display: grid; place-items: center; font: 800 calc(100cqw / var(--C) * .38)/1 var(--body); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .35); transition: transform .18s, opacity .18s; pointer-events: none; }
.pc.pop .face { transform: scale(.1) rotate(25deg); opacity: 0; }
.pc.born .face { animation: born .3s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes born { 0% { transform: scale(.2); } }
.pc.sel .face { transform: scale(1.12); filter: drop-shadow(0 0 0 var(--ink)); }
.pc.sel::after { content: ''; position: absolute; inset: 4%; border: 3px solid var(--ink); border-radius: 26%; background: rgba(255, 255, 255, .45); z-index: -1; }
.pc.hint .face { animation: hint .7s ease-in-out infinite; }
@keyframes hint { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.16) rotate(-6deg); } }
.pc.nope .face { animation: nope .3s; }
@keyframes nope { 25% { transform: translateX(-8%); } 75% { transform: translateX(8%); } }

/* the six snacks, drawn when the pictures are missing: each has its own colour, shape and letter */
.t0 .face { background: #b9742f; border-radius: 50%; border: 2px solid var(--ink); background-image: radial-gradient(circle at 30% 30%, #5a3210 0 7%, transparent 8%), radial-gradient(circle at 68% 38%, #5a3210 0 6%, transparent 7%), radial-gradient(circle at 42% 72%, #5a3210 0 7%, transparent 8%); }
.t1 .face { background: radial-gradient(circle, var(--felt) 0 17%, var(--ink) 18% 21%, #ff7fb0 22%); border-radius: 50%; border: 2px solid var(--ink); }
.t2 .face { background: #e23b34; border-radius: 46% 46% 50% 50% / 38% 38% 62% 62%; border: 2px solid var(--ink); }
.t2 .face::before { content: ''; position: absolute; top: -9%; left: 50%; width: 22%; height: 22%; background: #2e9e4a; border: 2px solid var(--ink); border-radius: 0 80% 0 80%; }
.t3 .face { background: #f2b21d; border-radius: 12%; border: 2px solid var(--ink); clip-path: polygon(8% 0, 92% 0, 100% 10%, 92% 20%, 100% 100%, 0 100%, 8% 20%, 0 10%); background-image: linear-gradient(#d43d2f 0 0); background-size: 100% 22%; background-position: 0 62%; background-repeat: no-repeat; }
.t4 .face { background: #5b3418; border-radius: 10%; border: 2px solid var(--ink); width: 70%; background-image: linear-gradient(rgba(255, 255, 255, .22) 2px, transparent 2px), linear-gradient(90deg, rgba(255, 255, 255, .22) 2px, transparent 2px); background-size: 50% 33.4%; }
.t5 .face { background: #ffe14a; border: 2px solid var(--ink); border-radius: 100% 0 100% 0 / 100% 0 100% 0; width: 66%; height: 66%; transform: rotate(8deg); color: var(--ink); text-shadow: none; }
.pc.pop.t5 .face { transform: scale(.1); }
body.has-cookie .t0 .face, body.has-doughnut .t1 .face, body.has-apple .t2 .face, body.has-crisps .t3 .face, body.has-chocolate .t4 .face, body.has-banana .t5 .face {
  background: center / contain no-repeat; border: 0; border-radius: 0; clip-path: none; width: 88%; height: 88%; font-size: 0; transform: none;
}
body.has-apple .t2 .face::before { content: none; }
body.has-cookie .t0 .face { background-image: url(/img/cookie.webp); }
body.has-doughnut .t1 .face { background-image: url(/img/doughnut.webp); }
body.has-apple .t2 .face { background-image: url(/img/apple.webp); }
body.has-crisps .t3 .face { background-image: url(/img/crisps.webp); }
body.has-chocolate .t4 .face { background-image: url(/img/chocolate.webp); }
body.has-banana .t5 .face { background-image: url(/img/banana.webp); }
body .pc.pop .face { transform: scale(.1) rotate(25deg); }
body .pc.sel .face { transform: scale(1.12); }

/* special snacks: an effect drawn over the snack */
.sp1 .face::after, .sp2 .face::after { content: ''; position: absolute; inset: -6%; border-radius: 28%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--ink), 0 0 10px 2px #fff; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .85) 0 11%, transparent 11% 25%); animation: glow 1.2s ease-in-out infinite; }
.sp2 .face::after { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .85) 0 11%, transparent 11% 25%); }
.sp1::before, .sp2::before { content: '\2194'; position: absolute; right: 2%; bottom: 0; z-index: 2; background: var(--ink); color: #fff; border-radius: 999px; font: 800 calc(100cqw / var(--C) * .24)/1 var(--body); padding: 2% 6%; }
.sp2::before { content: '\2195'; }
.sp3 .face::after { content: ''; position: absolute; inset: -9%; border-radius: 22%; border: 4px dashed var(--orange); box-shadow: 0 0 0 2px #fff, 0 0 12px 3px rgba(238, 79, 126, .8); background: linear-gradient(rgba(255, 255, 255, .0), rgba(255, 255, 255, .35)); animation: wrap 1.4s ease-in-out infinite; }
.sp3::before { content: '\2726'; position: absolute; right: 2%; top: 0; z-index: 2; background: var(--orange); color: #fff; border: 2px solid var(--ink); border-radius: 999px; font: 800 calc(100cqw / var(--C) * .22)/1 var(--body); padding: 2% 5%; }
.gold .face { background: radial-gradient(circle at 35% 30%, #fff7b0, #ffc800 55%, #e08a00) !important; border: 3px solid var(--ink) !important; border-radius: 50% !important; clip-path: none !important; width: 80% !important; height: 80% !important; color: var(--ink); text-shadow: 0 1px 0 #fff; font-size: calc(100cqw / var(--C) * .46) !important; box-shadow: 0 0 12px 3px rgba(255, 200, 0, .9); animation: glow 1s ease-in-out infinite; }
.gold .face::before { content: '\2605'; }
@keyframes glow { 50% { filter: brightness(1.18); } }
@keyframes wrap { 50% { transform: scale(1.06); } }

/* boxes */
.box .face { width: 92%; height: 92%; border-radius: 10%; border: 2px solid var(--ink); background: #c99a62; background-image: linear-gradient(90deg, transparent 44%, rgba(90, 50, 16, .35) 44% 56%, transparent 56%), linear-gradient(rgba(255, 255, 255, .18), rgba(0, 0, 0, .08)); font-size: 0; }
body.has-box .box .face { background: url(/img/box.webp) center / contain no-repeat; border: 0; }
.box2 .face::after { content: '2'; position: absolute; inset: 0; display: grid; place-items: center; font: 800 calc(100cqw / var(--C) * .3)/1 var(--body); color: var(--ink); text-shadow: 0 1px 0 #fff; background: linear-gradient(45deg, transparent 40%, rgba(240, 240, 240, .92) 40% 60%, transparent 60%), linear-gradient(-45deg, transparent 40%, rgba(240, 240, 240, .92) 40% 60%, transparent 60%); border-radius: 10%; }
.box.hit .face { animation: nope .25s; }

/* goal icons reuse the snack drawings */
.ico .face { width: 100%; height: 100%; font-size: 13px; position: absolute; inset: 0; }
.ico.t4 .face { width: 80%; left: 10%; } .ico.t5 .face { width: 80%; height: 80%; inset: 10%; }
body.has-cookie .ico.t0 .face, body.has-doughnut .ico.t1 .face, body.has-apple .ico.t2 .face, body.has-crisps .ico.t3 .face, body.has-chocolate .ico.t4 .face, body.has-banana .ico.t5 .face { width: 100%; height: 100%; inset: 0; font-size: 0; }
.ico.jelly { border-radius: 8px; background: #ffb3cf; box-shadow: inset 0 0 0 3px #ff6fa3; }
body.has-jelly .ico.jelly { background: url(/img/jelly.webp) center / contain no-repeat; box-shadow: none; }

/* result */
.result { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 16px; text-align: center; }
.result .prize { width: 150px; height: 150px; object-fit: contain; animation: prize .5s cubic-bezier(.3, 1.6, .5, 1); }
.result .stars { font-size: 54px; gap: 6px; }
.result .star.on { animation: prize .5s cubic-bezier(.3, 1.6, .5, 1) backwards; }
.result .star:nth-child(2) { animation-delay: .15s; transform: translateY(-8px); } .result .star:nth-child(3) { animation-delay: .3s; }
.banner { font: 34px/1.05 var(--display); color: var(--orange-dark); padding-top: 6px; }
@keyframes prize { 0% { transform: scale(.3) rotate(-20deg); opacity: 0; } }

@media (max-height: 700px) { h1 { font-size: 32px; } .mascot { width: 72px; height: 72px; } .hud { padding: 7px 10px; } }
@media (max-width: 380px) { .logo { font-size: 20px; } .hud { gap: 7px; } .goal { font-size: 14px; padding-right: 7px; } .map { gap: 10px 6px; } }
@media (prefers-reduced-motion: reduce) {
  .pc, .board[data-step] .pc, .face { transition: none !important; }
  .pc .face, .pc .face::after, .lv.now, .hud .mv.low b, .result .prize, .result .star.on, .status.pop, .gold .face { animation: none !important; }
  .pc.hint .face { outline: 3px dashed var(--ink); outline-offset: 2px; }
}
