/* Fridge Logic — retro fridge door styling.
 * Magnet size on the board is --m (set by the board's layout). */

:root {
  --ink: #1e3a44;
  --ink-soft: #3d5d68;
  --enamel: #f3f2ee;
  --enamel-hi: #fbfbf9;
  --enamel-lo: #e4e2dc;
  --enamel-deep: #cfccc4;
  --fridge-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='t' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.62' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeDiffuseLighting lighting-color='%23fff' surfaceScale='2.4' diffuseConstant='1.1'%3E%3CfeDistantLight azimuth='235' elevation='52'/%3E%3C/feDiffuseLighting%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='.2' intercept='.81'/%3E%3CfeFuncG type='linear' slope='.2' intercept='.81'/%3E%3CfeFuncB type='linear' slope='.2' intercept='.815'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23t)'/%3E%3C/svg%3E");
  --paper-shadow: 0 1px 2px rgba(0,0,0,.18), 0 8px 16px rgba(0,0,0,.07);
  --magnet-shadow: 0 3px 3px rgba(0,0,0,.26), 0 1px 1px rgba(0,0,0,.2);
  --paper: #fffdf7;
  --sun: #ffd84d;
  --tomato: #e63b2e;
  --ok: #2fa84f;
  --bad: #e63b2e;
  --mystery: #6f4fa3;
  --wall-a: #f4e7d0;
  --wall-b: #ecdcc0;
  --font: 'Fredoka', 'Baloo 2', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  --m: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--wall-a);
  background-image: repeating-conic-gradient(var(--wall-a) 0 25%, var(--wall-b) 0 50%);
  background-size: 44px 44px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; }
.noscript { text-align: center; padding: 40px; }

/* ---------- the fridge ---------- */
#app {
  position: relative;
  width: min(100vw, 480px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background-color: var(--enamel);
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.55) 0 4%, rgba(255,255,255,0) 15%, rgba(0,0,0,0) 80%, rgba(0,0,0,.07) 100%),
    var(--fridge-texture);
  background-blend-mode: normal, multiply;
  box-shadow: 0 0 0 2px #d8d5ce, 0 0 0 5px #bdb9b0, 0 20px 50px rgba(60, 40, 20, .35);
  user-select: none;
  -webkit-user-select: none;
}
@media (min-width: 520px) and (min-height: 700px) {
  #app { height: calc(100dvh - 32px); margin: 16px auto; border-radius: 30px; }
}
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ---------- shared bits ---------- */
.topbar {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background-color: var(--enamel);
  background-image: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0) 60%, rgba(0,0,0,.04)), var(--fridge-texture);
  background-blend-mode: normal, multiply;
  box-shadow: 0 2px 0 #fff, 0 6px 0 #c9c5bc, 0 8px 8px rgba(0,0,0,.14);
  margin-bottom: 6px;
  position: relative;
  z-index: 3;
}
.topbar .titles { flex: 1; min-width: 0; text-align: center; }
.kicker { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.title { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, #fff, #dfe6e9 60%, #b8c4c9);
  font-size: 19px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 0 var(--ink);
  display: grid; place-items: center;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.btn {
  border: 3px solid var(--ink);
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--sun); }
.btn.danger { background: #ff9b8f; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .go:focus-visible, .tmag:focus-visible, .plate:focus-visible, .gcard:focus-visible, .lvl:focus-visible, .menu-btn:focus-visible {
  outline: 3px dashed var(--ink); outline-offset: 3px;
}
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; font-size: inherit; color: inherit; }
.muted { color: var(--ink-soft); font-size: 14px; }
.center { text-align: center; }
.ok { color: var(--ok); }
.no { color: var(--bad); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(180deg, #ffffff, #e9eef0);
  border: 0;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--magnet-shadow), inset 0 -2px 0 rgba(0,0,0,.08);
}
.chip[hidden] { display: none; }
.stars { color: #c98f00; font-weight: 700; }

/* ---------- magnets ---------- */
.mag-svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1.5px rgba(0,0,0,.35)); }
.glyph { font-family: var(--font); font-weight: 700; }
.chipmag { display: inline-block; width: 26px; height: 26px; vertical-align: middle; margin: 1px; }
.shape-ic { width: 1.1em; height: 1.1em; vertical-align: -0.15em; }
.sw { display: inline-block; width: .95em; height: .95em; border-radius: 50%; border: 2px solid currentColor; flex: none; vertical-align: -0.1em; margin-right: 2px; }
.sw.strike { position: relative; }
.sw.strike::after { content: ''; position: absolute; left: -25%; right: -25%; top: 40%; height: 2px; background: currentColor; transform: rotate(-45deg); }
.c-red { background: #e63b2e; } .c-orange { background: #f78a1d; } .c-yellow { background: #fbd11b; }
.c-green { background: #2fa84f; } .c-blue { background: #1d7fe0; } .c-purple { background: #8d3bba; }
.c-white { background: #f3efe6; } .c-brown { background: #8b5a39; }

/* ---------- game: goals ---------- */
.goalbar {
  flex: none;
  display: flex; align-items: stretch; gap: 8px;
  padding: 8px 10px 6px;
}
.goals { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.goals::-webkit-scrollbar { display: none; }
.meta { flex: none; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; justify-content: center; }
.gcard {
  flex: 0 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px 5px 6px; margin-top: 4px;
  background: var(--paper);
  border: 0; border-radius: 4px;
  box-shadow: var(--paper-shadow);
  cursor: pointer; text-align: left;
  position: relative;
  rotate: -1.2deg;
  transition: background .2s;
}
.gcard:nth-child(2) { rotate: 1.4deg; }
.gcard::before { content: ''; position: absolute; top: -6px; left: 50%; width: 13px; height: 13px; margin-left: -6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffb3a8, #e63b2e 55%, #9e1f16); box-shadow: 0 2px 2px rgba(0,0,0,.3); }
.gicon { position: relative; flex: none; display: grid; place-items: center; min-width: 38px; height: 38px; }
.gart { display: inline-block; width: 38px; height: 38px; }
.gart.sm { width: 22px; height: 22px; }
.gword { display: flex; }
.gemo { font-size: 26px; line-height: 1; }
.gtxt-big { font-size: 17px; font-weight: 700; white-space: nowrap; }
.gdots { display: flex; gap: 2px; }
.gdots i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); }
.gcount { position: absolute; right: -8px; bottom: -4px; background: var(--ink); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 5px; line-height: 16px; }
.glabel { font-size: 13px; font-weight: 600; line-height: 1.15; max-width: 120px; }
.gcard.secret { background: #f3ecff; }
.gcard.secret::before { background: radial-gradient(circle at 35% 30%, #d9c6ff, #6f4fa3 55%, #43296e); }
.gcard.secret .gq { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--mystery); color: #fff; font-weight: 700; font-size: 22px; }
.gcard.met { background: #dcf8e2; }
.gcard.met::after { content: '✓'; position: absolute; top: -8px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--ink); }
.gcard.miss { background: #ffe3de; animation: shake .4s; }

/* ---------- game: the climb ---------- */
.door { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.door::after { /* chrome handle */
  content: '';
  position: absolute; right: 4px; top: 22%; height: 40%; width: 11px;
  border-radius: 7px;
  background: linear-gradient(90deg, #7e898e, #f5f8f9 38%, #c3cdd1 62%, #7a8489);
  box-shadow: -3px 4px 6px rgba(0,0,0,.28);
  pointer-events: none;
  z-index: 6;
}
.scroller { position: absolute; inset: 0; overflow: hidden; }
.scroller.free { overflow-y: auto; scroll-snap-type: y proximity; overscroll-behavior: contain; scrollbar-width: none; }
.scroller.free::-webkit-scrollbar { display: none; }
/* clip: a magnet flying in from the tray mustn't stretch the scroll range */
.tower { position: absolute; left: 0; right: 0; top: 0; will-change: transform; overflow: clip; }
.secs, .snaps, .lines, .mags, .fx { position: absolute; inset: 0; }
.snaps { z-index: 1; pointer-events: none; }
.mags, .fx { pointer-events: none; }
.fx { z-index: 4; }
.mags { z-index: 3; }
.lines { z-index: 2; pointer-events: none; }

.sec { position: absolute; left: 0; right: 0; scroll-snap-align: center; }
.sec .box {
  position: absolute; left: 38px; right: 22px; top: 36px; bottom: 28px;
  border-radius: 3px;
  background: #fffef9 repeating-linear-gradient(180deg, transparent 0 25px, rgba(80, 130, 190, .16) 25px 26px);
  background-position: 0 30px;
  box-shadow: var(--paper-shadow);
  rotate: var(--tilt, -.4deg);
}
.sec .box::before, .sec .box::after { /* the two magnets holding the sheet up */
  content: ''; position: absolute; top: -8px; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9fd0ff, #1d7fe0 55%, #0b4285);
  box-shadow: var(--magnet-shadow);
}
.sec .box::before { left: 14px; }
.sec .box::after { right: 14px; }
.sec .box.closed { background: #f0efeb repeating-linear-gradient(-45deg, rgba(30,58,68,.05) 0 10px, transparent 10px 20px); }
.door.dragging .sec .box { box-shadow: var(--paper-shadow), 0 0 0 4px rgba(255, 216, 77, .8); }
.sec-label { position: absolute; left: 40px; top: 5px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: rgba(30,58,68,.45); }
.sec-hint { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; font-size: 17px; font-weight: 600; color: rgba(30,58,68,.4); padding: 0 12px; }
.sec-tip { display: block; margin-top: 6px; font-size: 14px; color: rgba(30,58,68,.55); }
.finish-banner {
  position: absolute; left: 50%; top: 26px; transform: translateX(-50%) rotate(-2deg);
  padding: 5px 18px; font-weight: 700; font-size: 18px; letter-spacing: .08em; color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,.45);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 50%),
    repeating-conic-gradient(#222 0 25%, #555 0 50%) 0 0 / 14px 14px;
  box-shadow: var(--magnet-shadow), inset 0 -3px 0 rgba(0,0,0,.35);
}
.floor { position: absolute; left: 36px; right: 22px; height: 0; }
.floor span {
  position: absolute; left: 50%; top: -2px; transform: translateX(-50%) rotate(1deg);
  font-size: 12px; font-weight: 700; letter-spacing: .12em; color: #fff;
  background: linear-gradient(180deg, #5fd07c, #2fa84f 60%, #1d7a38); border-radius: 8px; padding: 1px 10px;
  box-shadow: var(--magnet-shadow);
}

/* gate lines: a row of rivets with a machine plate in the middle */
.gline { position: absolute; left: 0; right: 0; height: 0; }
.gline::before {
  content: ''; position: absolute; left: 6px; right: 6px; top: -7px; height: 14px; border-radius: 7px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0) 0 22px, rgba(0,0,0,.08) 22px 24px),
    linear-gradient(180deg, #93a8b1 0%, #647b85 55%, #4c636d 100%);
  box-shadow: 0 3px 3px rgba(0,0,0,.28), inset 0 2px 0 rgba(255,255,255,.45), inset 0 -2px 0 rgba(0,0,0,.15);
}
.gline.clue::before { background: repeating-linear-gradient(90deg, rgba(255,255,255,0) 0 22px, rgba(0,0,0,.08) 22px 24px), linear-gradient(180deg, #c4b1ea, #9a7fd0 55%, #7a5fb2); }
.gline.mystery::before { background: repeating-linear-gradient(90deg, rgba(255,255,255,0) 0 22px, rgba(0,0,0,.1) 22px 24px), linear-gradient(180deg, #9a79d1, #6f4fa3 55%, #4f337e); }
.plate {
  position: absolute; top: 0; transform: translate(-50%, -50%) rotate(-1.5deg);
  min-width: 104px; height: 46px; padding: 0 10px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 16px;
  background: linear-gradient(180deg, #ff8a7c 0%, #e63b2e 50%, #b8291f 100%);
  box-shadow: 0 5px 5px rgba(0,0,0,.28), inset 0 2px 0 rgba(255,255,255,.55), inset 0 -4px 0 rgba(0,0,0,.2);
  cursor: pointer; pointer-events: auto;
  font-family: var(--font);
}
.plate::before { /* glossy highlight on the plastic */
  content: ''; position: absolute; left: 8px; right: 8px; top: 3px; height: 38%; border-radius: 12px 12px 30px 30px;
  background: linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,0)); pointer-events: none;
}
.pl-screen {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  background: #fffdf5; color: var(--ink);
  border-radius: 8px; padding: 2px 9px; min-height: 28px;
  font-size: 16px; font-weight: 700; white-space: nowrap;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
}
.plate.long .pl-screen { font-size: 13px; }
.pl-sep { opacity: .55; font-size: .8em; }
.pl-clue { font-size: 16px; }
.pl-q { color: #fff; letter-spacing: .15em; font-size: 18px; }
.plate.mystery { background: linear-gradient(180deg, #a98bdc 0%, var(--mystery) 50%, #4b2f7a 100%); }
.plate.mystery .pl-screen { background: #3a2663; box-shadow: inset 0 1px 3px rgba(0,0,0,.5); }
.plate.clue { background: linear-gradient(180deg, #d9ccf2 0%, #a98bdc 50%, #7f63b8 100%); }
.plate.clue .pl-screen { background: #f4efff; }
.plate.revealed { background: linear-gradient(180deg, #fff3b0 0%, #f2c632 50%, #c39400 100%); }
.plate.active { box-shadow: 0 5px 5px rgba(0,0,0,.28), 0 0 0 5px rgba(255, 216, 77, .85), 0 0 24px rgba(255, 216, 77, .9); }
.plate.active .pl-screen { background: #fff7c2; }
.plate.just-revealed { animation: reveal .8s ease-out; }
.pips { position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); display: flex; gap: 3px; background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 5px; }
.pips i { width: 7px; height: 7px; border-radius: 50%; background: #d3dadd; }
.pips i.on { background: var(--mystery); }

/* progress rail */
.rail {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; align-items: center;
  background: linear-gradient(90deg, #eceae4, #ffffff 45%, #e2dfd8); border-radius: 999px; padding: 7px 5px;
  box-shadow: var(--magnet-shadow);
}
.rail.clickable .rail-dot, .rail.clickable .rail-flag { cursor: pointer; }
.rail-flag.here { filter: drop-shadow(0 0 3px rgba(230,59,46,.8)); }
.rail-flag { font-size: 13px; line-height: 1; }
.rail-line { width: 2px; height: 8px; background: rgba(30,58,68,.3); }
.rail-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; }
.rail-dot.closed { border-style: dashed; }
.rail-dot.done { background: var(--enamel-deep); }
.rail-dot.here { background: var(--tomato); box-shadow: 0 0 0 3px rgba(230,59,46,.3); }
.rail-dot.box { border-color: var(--tomato); } /* your box, while you scroll around */
.rail.at-top .rail-flag { animation: bob 1s ease-in-out infinite; }

/* moving parts */
.bm {
  position: absolute; left: 0; top: 0;
  width: var(--m); height: var(--m);
  margin: calc(var(--m) / -2) 0 0 calc(var(--m) / -2);
  padding: 0; border: 0; background: none;
  pointer-events: none;
}
.bm.fresh { pointer-events: auto; cursor: pointer; }
.bm.fresh::after { content: '×'; position: absolute; right: -6px; top: -6px; width: 17px; height: 17px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); font-size: 12px; line-height: 13px; font-weight: 700; }
.bm.popped .mag-svg { animation: popout .32s cubic-bezier(.3, 1.6, .5, 1); }
.bm.cheer .mag-svg { animation: cheer .6s ease-in-out 2; }
.bm.sad .mag-svg { transform: rotate(-8deg) translateY(3px); transition: transform .3s; }
.pusher { /* a zero-size anchor at the middle fingertip; the arm runs off down-left */
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  filter: drop-shadow(2px 7px 6px rgba(40, 30, 20, .22));
}
.pusher .hand-svg {
  position: absolute; left: 0; top: 0; width: calc(var(--m) * 1.2); height: calc(var(--m) * 1.2);
  overflow: visible;
}
.hand-svg .fingers, .hand-svg .thumb { transform-box: fill-box; transition: transform .12s ease-out; }
.hand-svg .fingers { transform-origin: 50% 100%; }
.hand-svg .thumb { transform-origin: 30% 100%; }
.pusher.pressing .hand-svg .fingers { transform: scale(1.02, .93); }
.pusher.pressing .hand-svg .thumb { transform: rotate(-8deg); }
.bubble {
  position: absolute; z-index: 6;
  transform: translate(0, -50%);
  background: #ffe1dc; border: 2.5px solid var(--ink); border-radius: 12px;
  padding: 3px 9px; font-size: 14px; font-weight: 700; white-space: nowrap;
  animation: bubble 2.2s forwards;
}
.bubble::after {
  content: ''; position: absolute; left: -8px; top: 50%; width: 11px; height: 11px;
  background: inherit; border-left: 2.5px solid var(--ink); border-bottom: 2.5px solid var(--ink);
  transform: translateY(-50%) rotate(45deg);
}
.poof { position: absolute; z-index: 6; font-size: calc(var(--m) * .85); transform: translate(-50%, -50%); animation: poof .7s forwards; }
.ghost {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none;
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  filter: drop-shadow(0 10px 8px rgba(0,0,0,.35));
}
.ghost .mag-svg { transform: rotate(-6deg) scale(1.08); }

/* sticky note */
.note {
  position: absolute; z-index: 7; top: 10px; left: 50%;
  transform: translateX(-50%) rotate(-1.2deg);
  width: min(88%, 380px);
  background: #fff59d;
  padding: 12px 14px 10px;
  box-shadow: 0 6px 12px rgba(0,0,0,.2);
  font-size: 15px; line-height: 1.35;
}
.note::before { content: ''; position: absolute; top: -9px; left: 50%; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff39a, #f2c632 55%, #a88400); box-shadow: var(--magnet-shadow); }
.note p { margin: 0 0 8px; }
.note-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-actions .linkish { font-size: 14px; font-weight: 600; }
.note[hidden] { display: none; }

/* dock: tray + controls */
.dock {
  flex: none;
  position: relative;
  margin: 0 10px calc(8px + env(safe-area-inset-bottom));
  border-radius: 8px 8px 22px 22px;
  background: linear-gradient(180deg, rgba(214, 233, 240, .75), rgba(182, 208, 218, .85));
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 8px 16px rgba(0,0,0,.16), inset 0 3px 0 rgba(255,255,255,.85), inset 0 -12px 18px rgba(70, 110, 125, .16);
  padding: 8px 8px 6px;
}
.dock::before { /* the bin's front lip */
  content: ''; position: absolute; left: 10px; right: 10px; top: -5px; height: 8px; border-radius: 6px;
  background: linear-gradient(180deg, #ffffff, #dce9ee); box-shadow: 0 2px 3px rgba(0,0,0,.15);
}
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 4px; min-height: 52px; }
.tmag {
  /* the dock's margins, padding and border take 44px, plus a 4px gap between magnets */
  --size: min(58px, calc((min(100vw, 480px) - 44px - (var(--n, 6) - 1) * 4px) / var(--n, 6)));
  width: var(--size); height: var(--size);
  padding: 2px; border: 0; background: none; cursor: pointer;
  touch-action: none;
  transition: transform .12s, opacity .15s, filter .15s;
}
.tmag:hover:not(:disabled):not(.used):not(.spent) { transform: translateY(-3px) rotate(-3deg); }
.tmag.used { opacity: .22; filter: grayscale(1); }
.tmag.spent { opacity: .55; }
.tmag.lifting { opacity: .3; }
.tmag:disabled { cursor: default; }
.controls { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 2px; }
.controls .btn { min-width: 88px; }
.go {
  width: 68px; height: 68px; border-radius: 50%; margin-bottom: 4px;
  border: 4px solid var(--ink);
  background: radial-gradient(circle at 35% 28%, #ff9d8f, #e63b2e 52%, #b3261c);
  color: #fff; font-size: 22px; font-weight: 700; letter-spacing: .02em;
  text-shadow: 0 2px 0 rgba(0,0,0,.3);
  box-shadow: 0 6px 0 var(--ink), 0 10px 16px rgba(0,0,0,.25), inset 0 3px 0 rgba(255,255,255,.4);
  cursor: pointer;
  transition: transform .06s, filter .15s;
}
.go:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink), inset 0 3px 0 rgba(255,255,255,.4); }
.go:disabled { filter: grayscale(.75) brightness(1.1); opacity: .75; cursor: default; }
.go.skip { background: radial-gradient(circle at 35% 28%, #fff4b0, #ffd84d 52%, #e0a800); color: var(--ink); text-shadow: none; font-size: 16px; }
.game.running .tmag { pointer-events: none; }

/* result panel: replaces the tray + controls so the finish stays visible */
.rpanel { display: none; }
.dock.show-panel .tray, .dock.show-panel .controls { display: none; }
.dock.show-panel .rpanel { display: block; }
.rpanel {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 16px;
  padding: 10px 12px 12px; max-height: 42vh; overflow: auto;
  animation: sheetin .22s cubic-bezier(.3, 1.2, .5, 1);
  user-select: text; -webkit-user-select: text;
}
.rpanel.win { background: #effbe9; }
.rpanel.lose { background: #fff5f2; }
.rp-title { margin: 0 0 4px; font-size: 21px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.rp-stars { font-size: 22px; letter-spacing: 1px; }
.rp-stars span { color: #d6dde0; -webkit-text-stroke: 1.5px var(--ink); }
.rp-stars span.on { color: #ffcf2e; animation: starpop .45s cubic-bezier(.3, 1.8, .5, 1) backwards; }
.rp-stars span.on:nth-child(2) { animation-delay: .15s; }
.rp-stars span.on:nth-child(3) { animation-delay: .3s; }
.rp-body { font-size: 15px; line-height: 1.35; }
.rp-body p { margin: 4px 0; text-align: center; }
.rp-body .goal-report { margin: 6px 0; }
.rp-body .goal-report li { padding: 5px 9px; margin: 4px 0; font-size: 14px; }
.rp-body .unlock { padding: 5px 10px; }
.rp-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

/* ---------- modals / sheets / toast ---------- */
.modal-back {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(20, 40, 48, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadein .15s;
}
.modal-back.closing, .sheet-back.closing { animation: fadeout .16s forwards; }
.modal {
  position: relative;
  width: 100%; max-width: 400px; max-height: 100%;
  overflow: auto;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 18px 18px 16px;
  animation: modalin .25s cubic-bezier(.3, 1.4, .5, 1);
  user-select: text; -webkit-user-select: text;
}
.modal-title { margin: 0 34px 8px; text-align: center; font-size: 25px; }
.modal-body { font-size: 16px; line-height: 1.4; }
.modal-body h3 { margin: 16px 0 6px; font-size: 17px; }
.modal-body p { margin: 8px 0; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.modal-x {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 2.5px solid var(--ink); background: #fff; cursor: pointer; font-size: 15px; font-weight: 700;
}
.sheet-back { position: absolute; inset: 0; z-index: 40; background: rgba(20, 40, 48, .2); display: flex; align-items: flex-end; animation: fadein .12s; }
.sheet {
  position: relative; width: 100%; max-height: 72%; overflow: auto;
  background: var(--paper);
  border-top: 3px solid var(--ink);
  border-radius: 22px 22px 0 0;
  padding: 16px 18px calc(22px + env(safe-area-inset-bottom));
  font-size: 16px; line-height: 1.4;
  animation: sheetin .22s cubic-bezier(.3, 1.2, .5, 1);
}
.sheet h3 { margin: 0 40px 8px 0; font-size: 20px; }
.sheet p { margin: 8px 0; }
.sheet .tag { font-size: 12px; background: #fff3b0; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 8px; vertical-align: 3px; }
.hints { padding-left: 22px; }
.hints li { margin: 4px 0; font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: 160px; z-index: 200;
  transform: translate(-50%, 20px);
  background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 999px;
  font-size: 15px; font-weight: 600; text-align: center;
  max-width: min(90vw, 420px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* results */
.big-stars { display: flex; justify-content: center; gap: 6px; font-size: 52px; line-height: 1; margin: 4px 0 8px; }
.big-stars span { color: #d6dde0; -webkit-text-stroke: 2px var(--ink); }
.big-stars span.on { color: #ffcf2e; animation: starpop .45s cubic-bezier(.3, 1.8, .5, 1) backwards; }
.big-stars span.on:nth-child(2) { animation-delay: .15s; }
.big-stars span.on:nth-child(3) { animation-delay: .3s; }
.unlock { background: #fff3b0; border-radius: 12px; padding: 8px 12px; text-align: center; }
.goal-report { list-style: none; padding: 0; margin: 10px 0; }
.goal-report li { padding: 7px 10px; border-radius: 10px; margin: 5px 0; background: #f3f7f5; }
.goal-report li.ok { background: #dcf8e2; }
.goal-report li.no { background: #ffe8e4; }
.goal-report li b { margin-right: 4px; }
.solution li { margin: 4px 0; }

.golf { text-align: center; margin: 4px 0 10px; }
.golf .strokes {
  display: inline-grid; place-items: center;
  width: 86px; height: 86px; border-radius: 50%;
  background: var(--sun); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  font-size: 42px; font-weight: 700;
}
.golf.under .strokes { background: #7ee29a; }
.golf.lost .strokes { background: #ff9b8f; }
.golf-term { font-size: 22px; font-weight: 700; margin-top: 10px; }
.share-grid {
  font-family: var(--font); font-size: 15px; line-height: 1.35;
  background: #f3f7f5; border: 2px dashed rgba(30,58,68,.3); border-radius: 12px;
  padding: 10px 12px; margin: 10px 0; white-space: pre-wrap; text-align: center;
}
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin: 12px 0 6px; }
.mini-stats.two { grid-template-columns: repeat(2, 1fr); }
.mini-stats b { display: block; font-size: 26px; line-height: 1.1; }
.mini-stats span { font-size: 12px; color: var(--ink-soft); }
.countdown { text-align: center; font-size: 15px; }
.countdown b { font-variant-numeric: tabular-nums; font-size: 18px; }
.dist { display: grid; gap: 4px; margin: 10px 0; }
.bar-row { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.bar-row span { width: 14px; text-align: right; }
.bar { background: #cfd8dc; color: var(--ink); border-radius: 6px; padding: 1px 8px; text-align: right; font-size: 14px; min-width: 24px; }
.bar.has { background: #7ee29a; }
.history { list-style: none; padding: 0; margin: 6px 0; font-size: 14px; }
.history li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed rgba(30,58,68,.2); }
.history .rowemo { flex: 1; text-align: center; letter-spacing: -1px; overflow: hidden; }
.history b.lost { color: var(--bad); }

/* help */
.how { padding-left: 20px; }
.how li { margin: 8px 0; }
.hint-note { background: #fff59d; border-radius: 10px; padding: 8px 12px; }
.paint { text-align: center; line-height: 2; }
.paint .chipmag { width: 22px; height: 22px; }

/* ---------- home ---------- */
.home-top {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 14px 18px;
  background-color: var(--enamel);
  background-image: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0) 60%, rgba(0,0,0,.04)), var(--fridge-texture);
  background-blend-mode: normal, multiply;
  box-shadow: 0 2px 0 #fff, 0 6px 0 #c9c5bc, 0 8px 8px rgba(0,0,0,.14);
  margin-bottom: 6px;
}
.home-date { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.home-date b { font-size: 18px; }
.home-date small { font-size: 13px; font-weight: 500; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-door { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; align-items: center; padding: 18px 20px 12px; overflow: auto; }
.logo { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 6px 0 4px; }
.logo-word { display: flex; justify-content: center; gap: 1px; }
.logo-mag { width: min(15vw, 62px); height: min(15vw, 62px); padding: 0; border: 0; background: none; cursor: pointer; transform: rotate(var(--r)); }
.logo-mag.wiggle { animation: wiggle .45s; }
.tagline { margin: 6px 0 18px; font-size: 17px; font-weight: 500; text-align: center; color: var(--ink-soft); }
.menu { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.menu-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 12px 16px;
  border: 3px solid var(--ink); border-radius: 20px;
  background: #fff;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  position: relative;
}
.menu-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.menu-btn.play { background: var(--sun); }
.menu-btn .mi { font-size: 26px; width: 34px; text-align: center; }
.menu-btn .mt { display: flex; flex-direction: column; min-width: 0; }
.menu-btn b { font-size: 21px; }
.menu-btn small { font-size: 14px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn .streak { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-weight: 700; font-size: 17px; }
.menu-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.menu-row .btn { padding: 8px 13px; font-size: 15px; }
.menu-row .btn.icon { padding: 8px 11px; }
.skiptut { align-self: center; font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.deco { position: relative; width: 100%; max-width: 360px; height: 70px; margin-top: auto; pointer-events: none; }
.deco .deco-mag {
  position: absolute; width: 50px; height: 50px; padding: 0; border: 0; background: none;
  pointer-events: auto; cursor: default; touch-action: manipulation;
}
.deco .d1 { left: 4%; top: 12px; --r: -12deg; }
.deco .d2 { left: 30%; top: 2px; --r: 10deg; width: 44px; height: 44px; }
.deco .d3 { right: 30%; top: 16px; --r: -6deg; }
.deco .d4 { right: 6%; top: 0; --r: 14deg; }
.deco .deco-mag { transform: rotate(var(--r)); }
.deco .deco-mag.wiggle { animation: wiggle .45s; }
.savenote { font-size: 13px; color: var(--ink-soft); margin: 6px 0 calc(4px + env(safe-area-inset-bottom)); text-align: center; }

/* ---------- level select ---------- */
.star-total { flex: none; font-weight: 700; font-size: 14px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 4px 9px; }
.tabs { flex: none; display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px 6px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 70px; padding: 6px 8px;
  border: 2.5px solid var(--ink); border-radius: 14px;
  background: rgba(255,255,255,.65); cursor: pointer;
  font-weight: 600; font-size: 13px;
}
.tab .ti { font-size: 17px; font-weight: 700; }
.tab.on { background: #fff; box-shadow: 0 4px 0 var(--ink); transform: translateY(-2px); }
.tab.locked { opacity: .55; }
.level-scroll { flex: 1; min-height: 0; overflow: auto; padding: 4px 16px 24px; position: relative; }
.chapter-blurb { margin: 6px 4px 14px; text-align: center; color: var(--ink-soft); font-size: 15px; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px 10px; }
.lvl {
  aspect-ratio: 1; border-radius: 14px;
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink), inset 0 4px 0 rgba(255,255,255,.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.lvl.c-yellow, .lvl.c-orange { color: var(--ink); text-shadow: 0 1px 0 rgba(255,255,255,.5); }
.lvl:nth-child(odd) { rotate: -2deg; }
.lvl:nth-child(3n) { rotate: 2deg; }
.lvl .ln { font-size: 22px; font-weight: 700; line-height: 1; }
.lvl .ls { font-size: 11px; letter-spacing: 1px; color: #fff3b0; text-shadow: 0 1px 0 rgba(0,0,0,.4); }
.lvl.tut .ls { font-size: 7.5px; letter-spacing: .04em; }
.lvl.c-yellow .ls, .lvl.c-orange .ls { color: #8a5a00; text-shadow: none; }
.lvl.locked { background: #cfd8dc; color: #78909c; text-shadow: none; box-shadow: 0 4px 0 #90a4ae; border-color: #90a4ae; cursor: default; }
.lvl.current { animation: bob 1.4s ease-in-out infinite; }
.lvl:active:not(.locked) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- loading ---------- */
.loading { align-items: center; justify-content: center; gap: 10px; font-size: 18px; font-weight: 600; }
.spinner { width: 70px; height: 70px; animation: spin 1.1s linear infinite; }
.spinner.still { animation: none; transform: rotate(-8deg); }
.loading.trouble { padding: 24px; text-align: center; }
.loading.trouble h2 { margin: 6px 0 0; font-size: 22px; }
.loading.trouble p { margin: 0 0 8px; font-weight: 500; color: var(--ink-soft); }

/* ---------- accounts ---------- */
.acct-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; max-width: 55%;
  font: 600 14px var(--font); color: var(--ink);
  padding: 5px 12px; border-radius: 999px; border: 2px solid var(--ink); background: #fff;
  box-shadow: 0 3px 0 var(--ink); cursor: pointer;
}
.acct-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.acct-btn.in { padding: 3px 10px 3px 3px; }
.acct-btn i {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-style: normal; font-weight: 700; color: #fff; background: var(--tomato);
}
.acct-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal.account .btn.block { display: block; width: 100%; margin: 8px 0; text-align: center; box-sizing: border-box; text-decoration: none; }
.acct-google { display: flex !important; align-items: center; justify-content: center; gap: 8px; }
.acct-google .g { font-weight: 700; color: #4285f4; font-size: 18px; }
.acct-or { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; color: var(--ink-soft); font-size: 13px; }
.acct-or::before, .acct-or::after { content: ''; flex: 1; height: 2px; background: #e6e2d8; }
.acct-form { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.acct-form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.acct-form input { font: 16px var(--font); color: var(--ink); border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px; background: #fff; }
.acct-form .btn.small { align-self: flex-start; }
.acct-msg { min-height: 1.2em; margin: 4px 0; font-size: 14px; font-weight: 600; color: #2a7a3b; }
.acct-msg.bad { color: #9e1f16; }
.acct-sync { font-size: 13px; color: var(--ink-soft); margin: 4px 0; }
.acct-links { text-align: center; font-size: 14px; margin: 4px 0 0; }

/* ---------- keyframes ---------- */
@keyframes shake { 0%, 100% { translate: 0; } 25% { translate: -5px; } 50% { translate: 5px; } 75% { translate: -3px; } }
@keyframes popout { 0% { transform: scale(.5); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes cheer { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px) rotate(-6deg); } }
@keyframes reveal { 0% { transform: translate(-50%, -50%) scale(1); } 35% { transform: translate(-50%, -50%) scale(1.25) rotate(-3deg); } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes bubble {
  0% { opacity: 0; transform: translate(-6px, -50%) scale(.7); }
  10% { opacity: 1; transform: translate(0, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(0, -90%); }
}
@keyframes poof { 0% { opacity: 1; transform: translate(-50%, -50%) scale(.4); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1.8); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes modalin { from { transform: scale(.85) translateY(20px); opacity: 0; } }
@keyframes sheetin { from { transform: translateY(100%); } }
@keyframes starpop { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: none; } }
@keyframes wiggle { 0%, 100% { transform: rotate(var(--r)); } 30% { transform: rotate(calc(var(--r) - 14deg)) scale(1.12); } 65% { transform: rotate(calc(var(--r) + 10deg)); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 400px) {
  .glabel { max-width: 96px; font-size: 12px; }
  .goalbar { padding-left: 8px; padding-right: 8px; }
}
@media (max-height: 640px) {
  .topbar { padding-top: calc(5px + env(safe-area-inset-top)); padding-bottom: 5px; }
  .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  .title { font-size: 17px; }
  .go { width: 58px; height: 58px; font-size: 19px; }
  .tmag { --size: min(48px, calc((min(100vw, 480px) - 64px) / var(--n, 6))); }
}
@media (prefers-reduced-motion: reduce) {
  .lvl.current, .rail.at-top .rail-flag { animation: none; }
}

/* ---------- review: scroll back through every stage after a try ---------- */
.review-hint {
  position: absolute; z-index: 7; left: 50%; top: 10px; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 999px; padding: 5px 12px;
  font-size: 13px; font-weight: 600; box-shadow: 0 4px 10px rgba(0,0,0,.2);
  pointer-events: none; animation: bob 1.6s ease-in-out infinite;
}
.review-hint[hidden] { display: none; }
.tobox { /* back to your box, after scrolling away to plan: just inside the bottom of the box in view */
  position: absolute; z-index: 7; left: 50%; bottom: 62px; transform: translateX(-50%);
  border: 0; border-radius: 999px; padding: 6px 14px;
  background: var(--ink); color: #fff; font: 600 14px var(--font); white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0,0,0,.25); cursor: pointer;
}
.tobox[hidden] { display: none; }
.snap {
  position: absolute; left: 0; top: 0;
  width: var(--m); margin: calc(var(--m) / -2) 0 0 calc(var(--m) / -2);
  display: flex; flex-direction: column; align-items: center;
}
.snap-mag { display: block; width: var(--m); height: var(--m); }
.snap.fell .snap-mag, .snap.destroyed .snap-mag { opacity: .5; }
.snap-new {
  position: absolute; left: -7px; top: -7px; width: 18px; height: 18px; border-radius: 50%;
  background: #2fa84f; color: #fff; font-size: 14px; line-height: 17px; text-align: center; font-weight: 700;
  box-shadow: var(--magnet-shadow);
}
.snap-tag {
  display: inline-flex; align-items: center; gap: 2px; margin-top: 1px;
  background: #fff; border-radius: 8px; padding: 0 6px; min-height: 18px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.snap-tag.ok { color: var(--ok); }
.snap-tag.no { color: var(--bad); }
.snap-mini { display: inline-block; width: 20px; height: 20px; }

/* ---------- Friddles: the riddle card and answer slots ---------- */
.gcard.riddle {
  flex: 1 1 auto; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 8px 10px 8px; rotate: -.6deg; max-width: none;
}
.gcard.riddle .rq { font-size: 14px; font-weight: 600; line-height: 1.25; }
.rslots { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.rword { display: inline-flex; flex-wrap: wrap; gap: 3px; max-width: 100%; }
.rtile {
  position: relative; display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: #f1efe9; box-shadow: inset 0 1px 2px rgba(0,0,0,.18);
  border-bottom: 3px solid #cfcbc2;
}
.rtile.exact { background: #e3f8e7; border-bottom-color: #2fa84f; }
.rtile.exact .mag-svg { width: 24px; height: 24px; }
.rtile.colour { background: #fff4c9; border-bottom-color: #e0a800; }
.rtile.colour b { font-size: 16px; color: #8a6d00; }
.rtile.colour i { position: absolute; right: -6px; top: -7px; font-style: normal; font-size: 11px; }
/* the rest of the answer, however long it is */
.rtile.more { width: auto; min-width: 38px; padding: 0 8px; background: transparent; box-shadow: none; border: 2px dashed #cfcbc2; font-weight: 700; color: rgba(30,58,68,.45); }
.rslots.big .rtile.more { min-width: 52px; font-size: 20px; }
.rslots.big .rtile { width: 36px; height: 36px; }
.rslots.big .rtile.exact .mag-svg { width: 34px; height: 34px; }
.rslots.big .rtile.colour b { font-size: 21px; }
.rslots.mini { display: inline-flex; vertical-align: middle; margin-right: 6px; }
/* answers over 7 characters: smaller slots (and long words wrap) */
.rslots.long .rtile { width: 21px; height: 21px; border-radius: 5px; border-bottom-width: 2px; }
.rslots.long .rtile.exact .mag-svg { width: 20px; height: 20px; }
.rslots.long .rtile.colour b { font-size: 13px; }
.rslots.big.long .rtile { width: 28px; height: 28px; }
.rslots.big.long .rtile.exact .mag-svg { width: 27px; height: 27px; }
.rslots.big.long .rtile.colour b { font-size: 17px; }
.gcard.riddle.met { background: #e9fbe9; }
.try-tiles { display: flex; justify-content: center; margin: 6px 0; }
.try-tiles .rslots { justify-content: center; }
.riddle-big { font-size: 19px; font-weight: 600; line-height: 1.3; }
.riddle-recap { font-size: 16px; font-weight: 600; margin: 4px 0; }
.legend { list-style: none; padding: 0; margin: 8px 0; }
.legend li { display: flex; align-items: center; margin: 4px 0; font-size: 14px; }
.logo-mag { width: min(19vw, 78px); height: min(19vw, 78px); }

/* ---------- the archive: a calendar of every day so far ---------- */
.arc-month { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 2px 12px; }
.arc-month h2 { flex: 1; margin: 0; text-align: center; font-size: 20px; }
.arc-month .icon-btn:disabled { opacity: .3; cursor: default; transform: none; box-shadow: 0 3px 0 var(--ink); }
.arc-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px 6px; }
.arc-wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.arc-day {
  aspect-ratio: 1; min-width: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 2.5px solid var(--ink); border-radius: 12px; background: #fff;
  box-shadow: 0 3px 0 var(--ink); cursor: pointer; font-family: var(--font); color: var(--ink);
}
.arc-day b { font-size: 17px; line-height: 1; }
.arc-day small { font-size: 11px; font-weight: 700; line-height: 1; min-height: 11px; white-space: nowrap; }
.arc-day:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.arc-day.won { background: #7ee29a; }
.arc-day.lost { background: #ffb3a8; }
.arc-day.playing { background: var(--sun); }
.arc-day.today { outline: 3px solid var(--tomato); outline-offset: 2px; }
.arc-day.today.new small { color: var(--tomato); }
.arc-day.off { border-color: transparent; box-shadow: none; background: transparent; color: rgba(30,58,68,.28); cursor: default; }
.arc-day.pad { visibility: hidden; }
.arc-legend { list-style: none; padding: 0; margin: 16px 0 4px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.arc-legend li { display: flex; align-items: center; gap: 5px; }
.arc-key { width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--ink); background: #fff; }
.arc-key.won { background: #7ee29a; }
.arc-key.lost { background: #ffb3a8; }
.arc-key.playing { background: var(--sun); }

/* ---------- debug mode: all riddles ---------- */
.menu-btn.debug { background: #e8e2ff; }
.dbg-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.dbg-tools select { font-family: var(--font); font-size: 14px; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 8px; background: #fff; color: var(--ink); margin-left: 4px; }
.dbg-tier { font-size: 16px; margin: 16px 4px 6px; }
.dbg-riddles { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.dbg-riddle {
  width: 100%; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
  background: var(--paper); border: 0; border-radius: 6px; padding: 7px 10px;
  box-shadow: var(--paper-shadow); font-family: var(--font); color: var(--ink);
}
.dbg-riddle:active { transform: translateY(1px); }
.dbg-riddle.done { background: #e9fbe9; }
.dbg-a { font-weight: 700; font-size: 15px; letter-spacing: .04em; }
.dbg-q { font-size: 13px; color: var(--ink-soft); line-height: 1.3; }

/* lines with many parts */
.plate.xlong { min-width: 150px; }
.plate.xlong .pl-screen { flex-wrap: wrap; font-size: 12px; gap: 2px 4px; max-width: 250px; padding: 2px 8px; }

/* ---------- hints ---------- */
.hint-btn { position: relative; font-size: 18px; }
.hint-btn[hidden] { display: none; }
.hint-btn i {
  position: absolute; right: -4px; top: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--tomato); color: #fff; font: 700 11px/16px var(--font); font-style: normal; box-sizing: border-box;
}
.tmag.hinted { position: relative; }
.tmag.hinted .mag-svg { filter: drop-shadow(0 0 5px #ffd54a) drop-shadow(0 0 2px #ffb300); }
.tmag .hint-tag {
  position: absolute; right: -2px; bottom: -2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: #ffd54a; color: var(--ink); border: 2px solid var(--ink); font: 700 11px/14px var(--font); box-sizing: border-box;
}
.hint-sheet h3 { margin: 0 0 4px; }
.hint-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.hint-list li { display: flex; align-items: center; gap: 8px; background: #fffbe6; border-radius: 10px; padding: 8px 10px; font-size: 15px; }
.hint-list li b.n { flex: none; width: 22px; height: 22px; border-radius: 50%; background: #ffd54a; display: grid; place-items: center; font-size: 12px; }
.hint-list li.new { animation: popout .35s; }
.hint-list .chipmag { width: 30px; height: 30px; flex: none; }
.hint-sheet .btn.block { display: block; width: 100%; margin-top: 8px; }

/* "or" between two checks on a line's plate */
.pl-or { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #fff;
  background: #7a57c9; border-radius: 6px; padding: 0 4px; margin: 0 2px; line-height: 15px; }

/* ---------- tutorial ---------- */
/* slim home buttons (First time?, Archive): as wide as Play, but one line so Play stays the star */
.menu-btn.slim { padding: 7px 14px; gap: 10px; border-width: 2px; border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
.menu-btn.slim:active { box-shadow: 0 1px 0 var(--ink); transform: translateY(2px); }
.menu-btn.slim .mi { font-size: 18px; width: 22px; }
.menu-btn.slim .slim-line { display: block; flex: 1; font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn.slim .slim-line b { font-size: 15px; }
.menu-btn.slim .lock { font-size: 14px; }
.menu-btn.tut { background: #e7f0ff; }
.tut-again { align-self: center; font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.coach { position: absolute; inset: 0; z-index: 35; pointer-events: none; }
.coach[hidden] { display: none; }
.coach-block { position: absolute; pointer-events: auto; }
.coach.whole .coach-hole + .coach-block { background: rgba(20, 30, 36, .45); }
.coach-hole {
  position: absolute; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(20, 30, 36, .45), 0 0 0 3px #ffd54a, 0 0 18px 4px rgba(255, 213, 74, .8);
  animation: coach-glow 1.6s ease-in-out infinite;
}
@keyframes coach-glow { 50% { box-shadow: 0 0 0 9999px rgba(20, 30, 36, .45), 0 0 0 3px #ffd54a, 0 0 26px 8px rgba(255, 213, 74, .95); } }
.coach-bubble {
  position: absolute; pointer-events: auto; box-sizing: border-box;
  background: #fffdf5; color: var(--ink); border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink), 0 12px 24px rgba(0, 0, 0, .25);
  padding: 12px 14px 10px; font-size: 16px; line-height: 1.35;
}
.coach.pop .coach-bubble { animation: popout .3s; }
.coach-text { margin: 0 0 8px; }
.coach-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.coach-actions .linkish { font-size: 13px; color: var(--ink-soft); }
.coach-actions .btn[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .coach-hole, .coach.pop .coach-bubble { animation: none; } }

/* How to play: play stats */
.stats-note { font-size: 14px; color: var(--ink-soft); }
.stats-note .check { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--ink); font-weight: 600; cursor: pointer; }
.stats-note .check input { width: 18px; height: 18px; accent-color: var(--tomato); }

/* ---------- what a line did: a change morphs, a fall lands in the pile ---------- */
.was { /* the ghost of what a magnet was, lifting off as it changes */
  position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none;
  width: var(--m); height: var(--m); margin: calc(var(--m) / -2) 0 0 calc(var(--m) / -2);
  filter: grayscale(.35) drop-shadow(0 4px 6px rgba(0,0,0,.25));
}
.burst {
  position: absolute; z-index: 2; pointer-events: none;
  width: calc(var(--m) * 1.1); height: calc(var(--m) * 1.1); margin: calc(var(--m) * -.55) 0 0 calc(var(--m) * -.55);
  border-radius: 50%; border: 4px solid var(--sun); box-shadow: 0 0 12px 2px rgba(255, 216, 77, .8), inset 0 0 10px rgba(255, 216, 77, .7);
  animation: burst .55s ease-out forwards;
}
@keyframes burst { 0% { transform: scale(.55); opacity: 1; } 100% { transform: scale(1.75); opacity: 0; } }
.faller {
  position: absolute; left: 0; top: 0; z-index: 8; pointer-events: none;
  width: var(--m); height: var(--m); margin: calc(var(--m) / -2) 0 0 calc(var(--m) / -2);
}
.pile { /* bottom left, in the margin beside the boxes: a heap of what fell off, newest on top */
  position: absolute; left: 5px; bottom: 6px; z-index: 7; width: 34px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px 3px;
  font: 600 10px/1.05 var(--font); color: var(--ink);
  background: rgba(255, 253, 247, .92); border: 2px solid rgba(30, 58, 68, .25); border-radius: 12px;
  box-shadow: 0 3px 8px rgba(0,0,0,.14); cursor: pointer;
}
.pile[hidden] { display: none; }
.pile.bump { animation: pile-bump .35s ease-out; }
@keyframes pile-bump { 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.pile-mags { display: flex; flex-direction: column-reverse; align-items: center; min-height: 6px; }
.pile-mag { width: 24px; height: 24px; transform: rotate(var(--r)); filter: saturate(.8); }
.pile-mag + .pile-mag { margin-bottom: -13px; }
.pile-mag.broke { position: relative; opacity: .8; }
.pile-mag.broke::after { content: '💥'; position: absolute; right: -5px; top: -5px; font-size: 10px; transform: rotate(calc(-1 * var(--r))); }
.pile-n { display: flex; flex-direction: column; align-items: center; margin-top: 2px; }
.pile-n b { font-size: 13px; color: var(--bad); }
.pile-list { list-style: none; padding: 0; margin: 8px 0; }
.pile-list li { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px dashed rgba(30,58,68,.15); }
.pile-list .chipmag { width: 32px; height: 32px; }
@media (prefers-reduced-motion: reduce) {
  .burst { animation: none; opacity: 0; }
  .pile.bump { animation: none; }
}
