@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; }

/* Filing Blocks palette: office steel, navy ink, folder orange and highlighter blue. */
:root {
  --bg: #e9eef6; --paper: #ffffff; --ink: #1f2a3a; --muted: #6a778a; --line: #c9d4e3;
  --aqua: #2f6fde; --aqua-dark: #1b4aa3; --orange: #f08a24; --orange-dark: #b05a08;
  --green: #23b67f; --red: #f0524f; --yellow: #ffd23f; --wood: #8fa1b8; --wood-dark: #5d6f87; --felt: #f4f7fb;
  --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(47, 111, 222, .10) 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(--aqua-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(31, 42, 58, .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(31, 42, 58, .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(31, 42, 58, .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 */
.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(--aqua-dark); }
.hud .mv.low b { color: var(--red); animation: bob .7s ease-in-out infinite; }
.hud .lvl.big b { font-size: 34px; color: var(--orange-dark); }
.goals { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.goal { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--line); border-radius: 999px; padding: 4px 11px; font-weight: 800; font-size: 15px; background: #fff; min-height: 34px; }
.goal small { font-size: 12px; font-weight: 600; color: var(--muted); }
.goal.done { background: #d5f5e7; border-color: var(--green); }
.goal.done .n::before { content: '\2713'; color: var(--green); }
.goal.done .n span { display: none; }
.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 cabinet */
.cabinet { background: var(--wood); border: 3px solid var(--ink); border-radius: 22px; padding: 8px; box-shadow: 0 6px 0 rgba(31, 42, 58, .2), inset 0 0 0 3px rgba(255, 255, 255, .22); }
.board { width: min(100%, calc(100dvh - 410px)); min-width: min(100%, 250px); aspect-ratio: 1; margin: 0 auto; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); gap: 2px; touch-action: none; user-select: none; -webkit-user-select: none; background: var(--wood-dark); border: 2px solid var(--wood-dark); border-radius: 10px; overflow: hidden; }
.cell { border: 0; padding: 0; margin: 0; min-width: 0; min-height: 0; background: var(--felt); position: relative; border-radius: 3px; touch-action: none; }
.cell:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; z-index: 1; }
.cell.pv::after { content: ''; position: absolute; inset: 0; background: rgba(35, 182, 127, .30); border-radius: inherit; }
.cell.will::before { content: ''; position: absolute; inset: 0; background: rgba(255, 210, 63, .5); border-radius: inherit; z-index: 1; }
.cell.zap { animation: zap .4s ease-out; }
@keyframes zap { 0% { background: #fff; box-shadow: inset 0 0 0 4px var(--yellow); transform: scale(1.08); z-index: 2; } 100% { transform: scale(1); } }
.cell.drop { animation: drop .18s ease-out; }
@keyframes drop { 0% { transform: scale(.7); } }

/* blocks: five office colours, each with its own pattern inside, so colour is never the only clue */
.c1, .c2, .c3, .c4, .c5, .paper, .stapled { border-radius: 5px; box-shadow: inset 0 0 0 2px var(--ink), inset 0 -4px 0 2px rgba(0, 0, 0, .14); }
.c1 { background: #3b82f6 repeating-linear-gradient(45deg, rgba(255, 255, 255, .34) 0 3px, transparent 3px 9px); }
.c2 { background: #ffd23f radial-gradient(circle, rgba(31, 42, 58, .55) 0 16%, transparent 18%); }
.c3 { background: #f2693d repeating-linear-gradient(0deg, rgba(255, 255, 255, .4) 0 2px, transparent 2px 8px); }
.c4 { background: #2fb673 linear-gradient(rgba(255, 255, 255, .45), rgba(255, 255, 255, .45)) center / 42% 42% no-repeat; }
.c5 { background: linear-gradient(45deg, transparent 44%, rgba(255, 255, 255, .5) 44% 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, rgba(255, 255, 255, .5) 44% 56%, transparent 56%), #9a5be0; }
.paper, .stapled { background: #b8c0cc repeating-linear-gradient(0deg, transparent 0 22%, rgba(31, 42, 58, .32) 22% 30%); }
.stapled > b { position: absolute; left: 12%; top: 14%; width: 46%; height: 16%; background: var(--ink); border-radius: 3px; transform: rotate(-24deg); box-shadow: 0 0 0 2px #fff; }
.cell.pv { box-shadow: inset 0 0 0 3px var(--green); }
.cell.will { box-shadow: inset 0 0 0 3px var(--yellow); }

/* the tray of three blocks */
.tray { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slot { aspect-ratio: 1 / .92; background: rgba(255, 255, 255, .6); border: 2px dashed var(--line); border-radius: 16px; display: grid; place-items: center; min-height: 84px; max-height: 150px; width: 100%; }
.piece { border: 0; background: none; padding: 8px; display: grid; gap: 2px; touch-action: none; cursor: grab; border-radius: 12px; min-width: 44px; min-height: 44px; place-content: center; }
.piece i { display: block; width: var(--u); height: var(--u); position: relative; }
.piece.sel { background: #fff3bf; box-shadow: 0 0 0 3px var(--ink); }
.piece.nofit { opacity: .4; }
.piece.lifted { visibility: hidden; }
.ghost { position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; display: grid; gap: 2px; filter: drop-shadow(0 8px 6px rgba(31, 42, 58, .35)); will-change: transform; }
.ghost i { display: block; width: var(--u); height: var(--u); position: relative; }
.ghost.back { transition: transform .16s ease-in, opacity .16s; opacity: .4; }

/* 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(--aqua-dark); padding-top: 6px; }
.bigscore { font: 64px/1 var(--display); color: var(--orange-dark); padding-top: 8px; }
@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; } .slot { min-height: 70px; } }
@media (max-width: 380px) { .logo { font-size: 20px; } .hud { gap: 7px; } .goal { font-size: 14px; padding: 4px 8px; } .map { gap: 10px 6px; } }
@media (prefers-reduced-motion: reduce) {
  .cell.zap, .cell.drop, .lv.now, .hud .mv.low b, .result .prize, .result .star.on, .status.pop { animation: none !important; }
  .ghost.back { transition: none; }
}
