/* Nine Lives. Mint café tiles, blueberry ink (Kento's eye ring), Kento-blue for your
   digits, honey for treats and stars, rose for gentle mistakes. */
:root {
  --wall: #d7e9dc;
  --wall-deep: #bfdcc8;
  --ink: #2c3e66;
  --ink-soft: #5b6b8f;
  --line: #d3dbe8;
  --blue: #4a7bd0;
  /* Unsolved cells are fully opaque: nothing of the picture shows until its part is solved. */
  --blue-wash: #e2ecfb;
  --blue-mid: #c6d8f6;
  --blue-sel: #b6cbf2;
  --honey: #f2b84b;
  --honey-deep: #c98a1e;
  --apricot: #ee9f6b;
  --rose: #cf4b6a;
  --rose-wash: #fde3e9;
  --paper: #fffcf6;
  --sheet: #fffcf6;
  --key: #fffdf9;
  --key-edge: #b7d3c0;
  --cell: 40px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tiles: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M0 1h48M0 25h48M1 0v24M25 24v24' stroke='%23ffffff' stroke-opacity='.55' stroke-width='2'/%3E%3C/svg%3E");
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  position: fixed;
  inset: 0;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background: var(--wall) var(--tiles);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn svg, .tool svg, .tab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
:is(.icon-btn, .tool, .key, .helper, .tab, .primary, .secondary, .stop, .chip, .buy, .album button, .picker button, .pic-choice):focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- Home ---------- */
.home {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}
.home-top {
  display: grid;
  gap: 2px;
  padding: calc(var(--sg-corner-top) - 2px) 16px 6px; /* the 48px top row centers the corner's Menu (shared/menu.css) */
}
.home-top .treats { margin-left: auto; }
.treats {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: #fff7e6;
  box-shadow: inset 0 0 0 2px #f6dca6;
  font-size: 19px;
  font-weight: 800;
  color: #8a5a12;
}
.treat-icon { display: inline-grid; width: 30px; height: 16px; }
.treat-icon svg { width: 100%; height: 100%; }

.tab-panels { flex: 1; min-height: 0; position: relative; }
.panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px 28px;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 -1px 0 rgba(44, 62, 102, 0.08), 0 -10px 24px -18px rgba(44, 62, 102, 0.4);
}
.tab {
  min-height: 54px;
  border: 0;
  background: none;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 14px;
}
.tab[aria-selected="true"] { color: var(--blue); background: #edf3fc; }

/* Journey map */
.journey-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 4px 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-soft);
}
.journey-stars { display: flex; align-items: center; gap: 5px; }
.star-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  background: linear-gradient(160deg, #ffe08a, var(--honey) 50%, #df9a25);
  clip-path: polygon(50% 0%, 61.8% 35%, 98% 35%, 68.5% 57%, 79.4% 91%, 50% 70%, 20.6% 91%, 31.5% 57%, 2% 35%, 38.2% 35%);
}
.chapter { position: relative; margin-bottom: 24px; }
.chapter-sign {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 18px -14px rgba(44, 62, 102, 0.9);
}
.chapter-sign.locked { background: rgba(44, 62, 102, 0.45); }
.chapter-glyph { width: 52px; height: 52px; border-radius: 12px; background: #fffcf6; display: grid; place-items: center; }
.chapter-glyph svg { width: 44px; height: 44px; }
.chapter-sign h2 { font-size: 22px; font-weight: 800; line-height: 1.05; }
.chapter-sign p { font-size: 15px; line-height: 1.25; opacity: 0.85; margin-top: 2px; }
/* Room under the sign so the current stop's glow never tucks under it. */
.trail { position: relative; padding-top: 16px; }
.trail svg.paws { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.stop-row { position: relative; height: 92px; }
.stop {
  position: absolute;
  top: 12px;
  width: 64px;
  height: 64px;
  margin-left: -32px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: #fffcf6;
  box-shadow: 0 0 0 4px #fff, 0 8px 14px -8px rgba(44, 62, 102, 0.6);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
}
.stop img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.stop.locked { background: rgba(255, 255, 255, 0.55); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6); color: rgba(44, 62, 102, 0.4); cursor: default; }
.stop.current { background: var(--blue); color: #fff; box-shadow: 0 0 0 4px #fff, 0 0 0 9px rgba(74, 123, 208, 0.25), 0 10px 18px -8px rgba(44, 62, 102, 0.7); }
.stop.current::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 3px solid rgba(74, 123, 208, 0.45);
  animation: beckon 2.4s ease-in-out infinite;
}
@keyframes beckon {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 0.2; }
}
.stop-label {
  position: absolute;
  top: 80px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  pointer-events: none;
}
.stop-label .mini-stars { display: inline-flex; gap: 1px; vertical-align: -2px; }
.mini-stars i {
  width: 13px;
  height: 13px;
  display: inline-block;
  background: #c9d3c8;
  clip-path: polygon(50% 0%, 61.8% 35%, 98% 35%, 68.5% 57%, 79.4% 91%, 50% 70%, 20.6% 91%, 31.5% 57%, 2% 35%, 38.2% 35%);
}
.mini-stars i.on { background: var(--honey); }
.stop-badge {
  position: absolute;
  right: -6px;
  bottom: -4px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 24px;
  box-shadow: 0 2px 4px rgba(44, 62, 102, 0.25);
}
.welcome {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  margin: 0 0 14px;
}
.welcome img { width: 64px; height: 64px; }
.welcome p {
  position: relative;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 4px;
  background: #fffcf6;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 600;
  box-shadow: 0 8px 18px -14px rgba(44, 62, 102, 0.7);
}
.journey-done {
  margin: 8px 0 20px;
  padding: 16px;
  border-radius: 18px;
  background: #fffcf6;
  text-align: center;
  font-size: 17px;
  font-weight: 700;
}
/* A real photo hides at this stop. */
.stop-photo {
  position: absolute;
  right: -7px;
  top: -7px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 4px rgba(44, 62, 102, 0.25);
}
.stop-photo svg, .album .empty .camera, .daily-camera svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linejoin: round;
}
.stop-photo svg { width: 16px; height: 16px; }
.stop.current .stop-photo { color: var(--blue); }
.stop.locked .stop-photo { color: rgba(44, 62, 102, 0.55); background: rgba(255, 255, 255, 0.9); }
/* Solved before it held this picture: worth going back for. */
.stop.cleared.missing { background: #fff7e6; color: #8a5a12; box-shadow: 0 0 0 4px #fff, 0 0 0 8px rgba(242, 184, 75, 0.5), 0 8px 14px -8px rgba(44, 62, 102, 0.6); }
.stop.cleared.missing .stop-photo { color: #8a5a12; }
.new-pic { color: #9a6514; font-weight: 800; }

/* Endless puzzles, at the end of the map */
.chapter.endless { margin-top: 4px; }
.endless-card { margin-top: 14px; border-top: 10px solid var(--blue); }
.endless-card .note { margin-bottom: 2px; }
.pic-choice {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 6px 12px 6px 6px;
  border: 2px solid rgba(44, 62, 102, 0.14);
  border-radius: 16px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.pic-thumb { width: 60px; height: 60px; border-radius: 11px; overflow: hidden; background: #eef3e8; display: grid; place-items: center; }
.pic-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic-thumb svg, .surprise svg { width: 30px; height: 30px; fill: none; stroke: var(--ink); stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.pic-text { display: grid; line-height: 1.2; min-width: 0; }
.pic-text b { font-size: 17px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pic-text small { font-size: 14px; font-weight: 600; color: var(--ink-soft); }

/* The picture picker */
.picker-sheet { width: min(380px, calc(100vw - 24px)); padding: 20px 14px 14px; }
.picker-sheet > p { margin: 6px 4px 0; font-size: 15px; }
.picker {
  list-style: none;
  margin: 12px 0 14px;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: min(52dvh, 430px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.picker button {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #eef3e8;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.picker img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker button[aria-pressed="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--blue); }
.surprise { display: grid; justify-items: center; gap: 2px; font-size: 12px; font-weight: 800; line-height: 1.05; color: var(--ink); }

/* Cards (daily, quick) */
.card {
  background: var(--sheet);
  border-radius: 22px;
  padding: 18px 16px 16px;
  margin-bottom: 16px;
  box-shadow: 0 12px 26px -20px rgba(44, 62, 102, 0.7);
}
.card h2 { font-size: 24px; font-weight: 800; line-height: 1.1; }
.card h3 { font-size: 16px; font-weight: 700; color: var(--ink-soft); margin: 14px 0 6px; }
.note { font-size: 15px; line-height: 1.35; color: var(--ink-soft); }
.daily-card { border-top: 10px solid var(--honey); }
.daily-date { font-size: 16px; color: var(--ink-soft); font-weight: 500; }
.daily-row { display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: center; margin: 14px 0; }
.daily-thumb {
  width: 92px;
  height: 92px;
  border-radius: 14px;
  background: #e8efe7;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.daily-thumb img { width: 100%; height: 100%; object-fit: cover; }
.daily-camera { color: #93b59e; display: grid; }
.daily-camera svg { width: 46px; height: 46px; stroke-width: 1.7; }
.daily-kind { font-size: 19px; font-weight: 800; line-height: 1.2; }
.daily-hint { font-size: 15px; font-weight: 700; color: #3d8a5f; line-height: 1.25; margin-top: 2px; }
.daily-streak { font-size: 15px; color: var(--ink-soft); margin-top: 4px; line-height: 1.3; }
.daily-earlier { margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 2px solid rgba(44, 62, 102, 0.14);
  background: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.chip[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip:disabled { opacity: 0.45; cursor: default; }
.chip .lock { width: 15px; height: 15px; margin: 0 4px -2px -2px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.quick-actions { display: grid; gap: 8px; margin-top: 16px; }

/* Café */
.cafe-room {
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 0 5px #fff, 0 14px 26px -18px rgba(44, 62, 102, 0.8);
  margin: 6px 4px 12px;
  background: #eef3e8;
  aspect-ratio: 1;
}
.cafe-room svg { display: block; width: 100%; height: 100%; }
.cafe-room .cat { cursor: pointer; }
.cafe-room .cat.happy { animation: hop 0.5s cubic-bezier(0.3, 1.5, 0.5, 1); transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes hop { 40% { transform: translateY(-6%); } }
.cafe-room .records { cursor: pointer; }
.cafe-room .records.playing .disc { animation: spin 1.2s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.cafe-room .fish { animation: swim 5s ease-in-out infinite alternate; }
@keyframes swim { from { transform: translateX(-3px); } to { transform: translateX(2px); } }
.cafe-room .neon-text { animation: neon 4s ease-in-out infinite; }
@keyframes neon { 0%, 100% { opacity: 1; } 50% { opacity: 0.86; } }
.heart-pop {
  position: fixed;
  z-index: 40;
  width: 22px;
  height: 22px;
  pointer-events: none;
  animation: heart-up 1s ease-out forwards;
}
@keyframes heart-up { from { transform: translate(-50%, 0) scale(0.6); opacity: 1; } to { transform: translate(-50%, -46px) scale(1.1); opacity: 0; } }
.cafe-hint { text-align: center; font-size: 15px; color: var(--ink-soft); margin: 0 8px 10px; }
/* The shop is the café's own menu card: one sheet, items ruled off with dotted lines. */
.shop {
  list-style: none;
  margin: 0;
  padding: 6px 16px 10px;
  border-radius: 18px;
  background: var(--sheet);
  box-shadow: 0 12px 26px -20px rgba(44, 62, 102, 0.7);
  border-top: 10px solid var(--ink);
}
.shop li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 2px dotted rgba(44, 62, 102, 0.18);
}
.shop li:last-child { border-bottom: 0; }
.shop li.owned .item-name { color: var(--ink-soft); }
.shop .item-name { font-size: 17px; font-weight: 800; line-height: 1.15; }
.shop .item-note { font-size: 14px; color: var(--ink-soft); line-height: 1.3; }
.shop li.fav .item-note { color: #8a5a12; font-weight: 700; }
.buy {
  min-width: 92px;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: #fff3d8;
  box-shadow: inset 0 0 0 2px #f2cf86;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 17px;
  font-weight: 800;
  color: #8a5a12;
  cursor: pointer;
}
.buy .treat-icon { width: 24px; height: 13px; }
.buy:disabled { background: transparent; box-shadow: inset 0 0 0 2px rgba(44, 62, 102, 0.12); color: var(--ink-soft); cursor: default; }
.buy:disabled .treat-icon { filter: grayscale(1); opacity: 0.5; }
.buy.owned { box-shadow: none; background: none; color: #3d8a5f; }

/* Album */
.album-count { font-size: 16px; font-weight: 700; color: var(--ink-soft); padding: 2px 4px 10px; }
.album { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
.album button {
  width: 100%;
  border: 0;
  padding: 6px 6px 4px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 8px 14px -10px rgba(44, 62, 102, 0.7);
  cursor: pointer;
  display: grid;
  gap: 2px;
  text-align: center;
}
.album li:nth-child(3n + 1) button { transform: rotate(-1.5deg); }
.album li:nth-child(3n) button { transform: rotate(1.2deg); }
.album img { width: 100%; aspect-ratio: 1; display: block; border-radius: 2px; }
.album .cap { font-size: 12px; font-weight: 700; line-height: 1.15; min-height: 28px; display: grid; place-items: center; }
.album .empty .camera { width: 20px; height: 20px; }
.album .empty {
  aspect-ratio: 1;
  border-radius: 4px;
  border: 2px dashed rgba(44, 62, 102, 0.2);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(44, 62, 102, 0.45);
}

/* ---------- Puzzle ---------- */
.play {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--sg-corner-top) - 4px) 6px calc(var(--safe-bottom) + 10px);
}
.play-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; min-height: 52px; padding: 0 4px; }
.play-top > .sg-corner-slot { margin-left: calc(var(--sg-corner-left) - 10px); } /* under the corner's menu button (shared/menu.css) */
.play-title { text-align: center; line-height: 1.1; }
.play-title h2 { font-size: 21px; font-weight: 800; }
.play-title p { font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.hud { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; min-height: 38px; padding: 0 6px 4px; }
.purr {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 700;
  transition: background 0.3s, color 0.3s;
}
.purr-paw { width: 22px; height: 22px; fill: currentColor; opacity: 0.6; }
.purr-label b { font-weight: 800; }
.purr-bar { width: 46px; height: 6px; border-radius: 3px; background: rgba(44, 62, 102, 0.12); overflow: hidden; }
/* Fills toward the next purr tier (3, then 10) as right numbers go in; it never drains with time. */
.purr-bar i { display: block; height: 100%; width: 100%; background: currentColor; transform-origin: 0 50%; transform: scaleX(0); border-radius: 3px; transition: transform 0.35s ease-out; }
.purr.warm { background: #fff3d8; color: #9a6514; }
.purr.warm .purr-paw { opacity: 1; fill: var(--honey-deep); }
.purr.full .purr-bar { background: rgba(223, 154, 37, 0.25); }
.purr.full .purr-bar i { background: var(--honey-deep); }
.purr.bump { animation: purr-bump 0.4s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes purr-bump { 40% { transform: scale(1.08); } }
.mistakes { font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.mistakes.some { color: var(--rose); }
.clock { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
/* The clock is off unless she turns it on in settings. */
body.no-clock .hud { grid-template-columns: 1fr auto; }
body.no-clock .clock { display: none; }

.board-wrap { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; padding: 2px 0 8px; }
.board {
  position: relative;
  width: calc(var(--cell) * 9);
  height: calc(var(--cell) * 9);
  border-radius: 10px;
  box-shadow: 0 0 0 4px #fffcf6, 0 18px 30px -18px rgba(44, 62, 102, 0.8);
  background: #fffcf6;
  outline: none;
}
.board:focus-visible { box-shadow: 0 0 0 4px #fffcf6, 0 0 0 7px var(--ink); }
.picture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  pointer-events: none;
  /* play.js masks the picture to the solved cells (none at first). */
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(9, var(--cell));
  grid-template-rows: repeat(9, var(--cell));
  border-radius: 10px;
  overflow: hidden;
  transition: opacity 1.1s ease 0.3s;
}
.marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; transition: opacity 1s ease 0.2s; }
.cell {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--paper);
  cursor: pointer;
  font-size: calc(var(--cell) * 0.64);
  line-height: 1;
}
.cell.diag { background: #f1f6ff; }
.cell.paw::before {
  content: "";
  position: absolute;
  inset: 16%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='%23ee9f6b' d='M50 88 C30 88 24 70 34 60 C42 52 58 52 66 60 C76 70 70 88 50 88Z M22 52 a10 13 -20 1 0 0.1 0Z M40 36 a10 13 -8 1 0 0.1 0Z M60 36 a10 13 8 1 0 0.1 0Z M78 52 a10 13 20 1 0 0.1 0Z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0.32;
  pointer-events: none;
}
.cell.hl { background: var(--blue-wash); }
.cell.same { background: var(--blue-mid); }
.cell.sel { background: var(--blue-sel); box-shadow: inset 0 0 0 2.5px var(--blue); }
.cell.wrong { background: var(--rose-wash); }
.cell .d { position: relative; font-weight: 700; color: var(--blue); padding-top: 0.08em; }
.cell.given .d { font-weight: 800; color: var(--ink); }
.cell.wrong .d { color: var(--rose); }
.cell.same .d { font-weight: 800; }
.cell.peeked::after {
  content: "";
  position: absolute;
  top: 7%;
  right: 7%;
  width: 24%;
  height: 24%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath fill='%23ee9f6b' d='M50 88 C30 88 24 70 34 60 C42 52 58 52 66 60 C76 70 70 88 50 88Z M22 52 a10 13 -20 1 0 0.1 0Z M40 36 a10 13 -8 1 0 0.1 0Z M60 36 a10 13 8 1 0 0.1 0Z M78 52 a10 13 20 1 0 0.1 0Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.notes {
  position: absolute;
  inset: 4%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  font-size: calc(var(--cell) * 0.25);
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1;
}
.cell.label .notes { inset: 14% 4% 4% 14%; }
.notes i { font-style: normal; width: 100%; height: 100%; display: grid; place-items: center; border-radius: 30%; }
.notes i.match { background: var(--blue); color: #fff; }

/* Endless puzzles: the picture is already hers, so it shows softly through the paper from
   the start, faint enough that every digit and note stays easy to read. */
.board.ghost .cell:not(.open) { background: rgba(255, 252, 246, 0.76); }
.board.ghost .cell.diag:not(.open) { background: rgba(241, 246, 255, 0.76); }
.board.ghost .cell.hl:not(.open) { background: rgba(226, 236, 251, 0.86); }
.board.ghost .cell.same:not(.open) { background: rgba(198, 216, 246, 0.9); }
.board.ghost .cell.sel:not(.open) { background: rgba(182, 203, 242, 0.92); }
.board.ghost .cell.wrong:not(.open) { background: rgba(253, 227, 233, 0.92); }
/* Opening a puzzle puts the paper back with no fade (see play.js). */
.board.instant .cells, .board.instant .marks, .board.instant .cell { transition: none !important; }

/* Uncovered cells: the paper lifts and the picture shows through. */
.cell.open { background: rgba(255, 252, 246, 0.16); }
.cell.open.diag { background: rgba(255, 252, 246, 0.16); }
.cell.open.hl { background: rgba(226, 236, 251, 0.42); }
.cell.open.same { background: rgba(198, 216, 246, 0.6); }
.cell.open.sel { background: rgba(182, 203, 242, 0.7); }
.cell.open::before { opacity: 0; }
.cell.open .d {
  color: var(--ink);
  /* A soft white halo keeps digits readable over dark parts of a picture too. */
  text-shadow: 0 0 1px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 5px #fff, 0 0 9px rgba(255, 255, 255, 0.9);
}
.cell.revealing { transition: background-color 0.55s ease var(--d, 0s); }
.cell.revealing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 20%, rgba(255, 246, 214, 0.6) 40%, transparent 70%);
  opacity: 0;
  animation: shimmer 0.7s ease-out var(--d, 0s);
  pointer-events: none;
}
@keyframes shimmer { 0% { opacity: 0; transform: scale(0.4); } 35% { opacity: 1; } 100% { opacity: 0; transform: scale(1.3); } }
.cell .d.pop { animation: pop 0.24s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: scale(0.5); opacity: 0.4; } }
.cell.wrong .d.pop { animation: wobble 0.42s ease-in-out; }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg); } 60% { transform: rotate(9deg); } }
.cell.shake .d { animation: wobble 0.42s ease-in-out; }
.cell.swat .d { animation: swat 0.4s ease-in forwards; }
@keyframes swat { to { transform: translate(140%, -60%) rotate(40deg); opacity: 0; } }
.cell.peek-in { animation: peek-glow 0.9s ease-out; }
@keyframes peek-glow { 0% { box-shadow: inset 0 0 0 calc(var(--cell) / 2) rgba(238, 159, 107, 0.6); } 100% { box-shadow: inset 0 0 0 0 rgba(238, 159, 107, 0); } }

.lift-tile {
  position: fixed;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--paper);
  border-radius: 4px;
  color: var(--blue);
  font-weight: 700;
  line-height: 1;
  padding-top: 0.08em;
  pointer-events: none;
}
.board.done .cells { opacity: 0; }
.board.done .marks { opacity: 0; }
.board.done .picture { animation: settle 1.4s ease-out; }
@keyframes settle { from { filter: saturate(0.7) brightness(1.08); } to { filter: none; } }

/* Marks layer (SVG, 100 units per cell) */
.marks .thin { stroke: var(--line); stroke-width: 2.4; }
.marks .thick { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; opacity: 0.85; }
.marks .frame { fill: none; stroke: var(--ink); stroke-width: 9; }
.marks .diag-line { stroke: var(--blue); stroke-width: 5; stroke-dasharray: 2 13; stroke-linecap: round; opacity: 0.7; }
.marks .cage { fill: none; stroke: #b5793a; stroke-width: 3.2; stroke-dasharray: 9 7; stroke-linecap: round; transition: opacity 0.6s; }
.marks .cage-tag { fill: #fff6e3; stroke: #e6c38c; stroke-width: 2; }
.marks .cage-sum { fill: #8a5a12; font: 800 25px "Baloo 2", ui-rounded, sans-serif; }
.marks .dot { fill: #fff; stroke: #b5793a; stroke-width: 5; transition: opacity 0.6s; }
.marks .faded { opacity: 0.25; }

/* Controls */
/* The three cats, side by side under the board, each saying what it does. */
.helpers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; padding: 0 6px 10px; }
.helper {
  position: relative;
  min-width: 0;
  min-height: 52px;
  border: 0;
  padding: 5px 6px 5px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  text-align: left;
  cursor: pointer;
}
.helper .face {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fffcf6;
  box-shadow: 0 0 0 2px #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.helper .face img { width: 116%; height: 116%; margin-top: 10%; }
.helper .txt { display: grid; min-width: 0; line-height: 1.1; }
.helper .name { font-size: 15px; font-weight: 800; }
/* Never cut off: if a phone's font runs wide, the job wraps to a second line instead. */
.helper .verb { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.helper .left {
  position: absolute;
  top: -3px;
  left: 33px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--honey);
  color: #5a3a08;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.helper:disabled { cursor: default; background: rgba(255, 255, 255, 0.36); }
.helper:disabled .face { filter: grayscale(0.85); opacity: 0.55; }
.helper:disabled .txt { opacity: 0.55; }
.helper:disabled .left { background: #d5dbe5; color: var(--ink-soft); }
.helper.guarding { background: #fff3d8; box-shadow: inset 0 0 0 2px var(--honey); }
.helper.guarding .face { filter: none; opacity: 1; }
.helper.guarding .txt { opacity: 1; }
.helper.busy .face { animation: hop 0.5s cubic-bezier(0.3, 1.5, 0.5, 1); }

.controls { display: grid; grid-template-columns: minmax(84px, 0.34fr) 1fr; gap: 10px; padding: 0 6px; }
.tools { display: grid; grid-template-rows: repeat(3, 1fr); gap: 7px; }
.tool {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.tool:disabled { opacity: 0.4; cursor: default; }
.tool[aria-pressed="true"] { background: var(--ink); color: #fff; }
.tool:active:not(:disabled), .key:active:not(:disabled) { transform: translateY(2px); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.key {
  position: relative;
  min-height: clamp(48px, 7.3dvh, 64px);
  border: 0;
  border-radius: 14px;
  background: var(--key);
  box-shadow: 0 3px 0 var(--key-edge);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}
.key b { padding-top: 0.1em; font-weight: 800; }
.key small {
  position: absolute;
  right: 7px;
  bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}
.key.done { opacity: 0.35; box-shadow: 0 3px 0 rgba(183, 211, 192, 0.5); }
.key:disabled { opacity: 0.35; cursor: default; }
.keypad.pencil .key { background: #eef3fc; box-shadow: 0 3px 0 #c3d4ef; }
.keypad.pencil .key b { position: absolute; left: calc(15px + (100% - 30px) * var(--fx)); top: calc(13px + (100% - 26px) * var(--fy)); transform: translate(-50%, -50%); padding: 0; font-size: 16px; color: var(--blue); }
.keypad.pencil .key small { display: none; }

/* ---------- Overlays ---------- */
.loading {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(215, 233, 220, 0.6);
  font-size: 19px;
  font-weight: 700;
}
.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 64px);
  transform: translate(-50%, -8px);
  width: max-content;
  max-width: calc(100vw - 40px);
  padding: 9px 16px;
  border-radius: 14px;
  background: rgba(44, 62, 102, 0.95);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sheet {
  width: min(350px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 26px;
  padding: 24px 20px 20px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 24px 60px -20px rgba(44, 62, 102, 0.7);
  text-align: center;
}
.sheet::backdrop { background: rgba(44, 62, 102, 0.42); }
.sheet[open] { animation: sheet-in 0.3s cubic-bezier(0.3, 1.3, 0.5, 1); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
.sheet h2 { font-size: 28px; font-weight: 800; line-height: 1.1; }
.sheet > p { margin: 8px 0 18px; font-size: 17px; line-height: 1.4; color: var(--ink-soft); }
.primary, .secondary {
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0 12px;
}
.primary { border: 0; background: var(--ink); color: #fff; }
.secondary { border: 2px solid rgba(44, 62, 102, 0.16); background: transparent; color: var(--ink); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.menu-list { display: grid; gap: 8px; margin-top: 16px; text-align: left; }

.tip-art { margin: -4px auto 12px; width: 220px; height: 120px; }
.tip-art svg { width: 100%; height: 100%; }

.polaroid {
  margin: -6px auto 14px;
  width: 190px;
  padding: 9px 9px 0;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 14px 24px -14px rgba(44, 62, 102, 0.8), 0 0 0 1px rgba(44, 62, 102, 0.06);
  transform: rotate(-2deg);
}
.polaroid img { display: block; width: 100%; aspect-ratio: 1; border-radius: 2px; }
.polaroid figcaption { font-size: 15px; font-weight: 700; padding: 6px 2px 8px; line-height: 1.2; }
.polaroid.big { width: min(290px, 100%); }
.win-sheet[open] .polaroid { animation: drop-in 0.6s cubic-bezier(0.3, 1.3, 0.5, 1) both; }
@keyframes drop-in { from { transform: translateY(-30px) rotate(-8deg) scale(0.9); opacity: 0; } to { transform: rotate(-2deg); opacity: 1; } }
.win-stars { display: flex; justify-content: center; align-items: flex-end; gap: 8px; height: 56px; margin-bottom: 6px; }
.star {
  width: 42px;
  height: 42px;
  background: #dfe4ec;
  clip-path: polygon(50% 0%, 61.8% 35%, 98% 35%, 68.5% 57%, 79.4% 91%, 50% 70%, 20.6% 91%, 31.5% 57%, 2% 35%, 38.2% 35%);
}
.star.big { width: 54px; height: 54px; margin-bottom: 4px; }
.star.earned.pop { background: linear-gradient(160deg, #ffe08a 0%, var(--honey) 45%, #df9a25 100%); animation: star-pop 0.42s cubic-bezier(0.3, 1.8, 0.5, 1) both; }
@keyframes star-pop { from { transform: scale(0.2) rotate(-25deg); } to { transform: none; } }
.goals { list-style: none; margin: 10px 0 4px; padding: 0; display: grid; gap: 4px; text-align: left; }
.goals li { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.goals li::before {
  content: "";
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e7ebf1 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 12h8' stroke='%2393a0ba' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.goals li.met { color: var(--ink); }
.goals li.met::before {
  background: #3c9a6c url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' stroke='%23fff' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.win-treats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 12px 0 2px;
  font-size: 22px;
  font-weight: 800;
  color: #8a5a12;
}
.win-treats .treat-icon { width: 36px; height: 19px; }
.win-treats small { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.win-note { margin: 2px 0 0 !important; font-size: 15px !important; }
/* Only with the clock on: a plain line under the goals, lined up with their text. */
.win-time { margin: 4px 0 0 30px !important; font-size: 15px !important; font-weight: 600; text-align: left; font-variant-numeric: tabular-nums; }

/* Compact phones, 375 px wide included, so the cats' jobs keep room to spare. */
@media (max-width: 380px) {
  .key { font-size: 26px; }
  .tool { font-size: 14px; gap: 4px; }
  .tool svg { width: 21px; height: 21px; }
  .helpers { gap: 5px; padding: 0 4px 8px; }
  .helper { gap: 4px; padding-right: 4px; }
  .helper .face { width: 38px; height: 38px; }
  .helper .left { left: 29px; }
  .helper .name { font-size: 14px; }
  .helper .verb { font-size: 11px; }
  .controls { gap: 8px; padding: 0 4px; }
}
@media (max-height: 700px) {
  .key { min-height: 44px; }
  .tool { min-height: 44px; }
  .helper { min-height: 46px; }
  .helper .face { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .stop.current::after { animation: none; }
}

/* Title screen: the shared layout (shared/mainmenu.js); these are only Nine Lives' colors. */
#mm {
  --sg-bg: var(--wall) var(--tiles);
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: var(--ink); --sg-title-shadow: 0 2px 0 #fff;
  --sg-accent: var(--blue); --sg-accent-ink: #fff;
  --sg-card: var(--paper); --sg-card-ink: var(--ink); --sg-line: var(--line);
}
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--ink); --sg-accent: var(--blue); --sg-accent-ink: #fff; --sg-ink-soft: var(--ink-soft); }

/* iPhone: no double-tap zoom anywhere. touch-action isn't inherited, so it goes on every element
   (anything with its own touch-action keeps it). Text fields stay selectable. */
* { touch-action: manipulation; }
input, textarea { -webkit-user-select: text; user-select: text; }
