/* Cat Burglar: a night-blue page, rows of cat things, a paw and a ring for each clue. The title screen and the sheets are
   shared/mainmenu.js (menu.css, loaded after this); only their colors are set here (--sg-*). */
:root {
  --bg: #2a3558; --bg-hi: #4a5a8c; --ink: #fff6e8; --ink-soft: #b9c3e0; --line: rgba(255, 246, 232, 0.2);
  --accent: #f2b246; --accent-ink: #2a2230; --accent-dark: #8a5a10; --sheet: #fff8ee; --sheet-ink: #3b2a22; --sheet-soft: #7b5d4c;
  --cell: #fff8ee; --hole: rgba(255, 255, 255, 0.09);
  --win: #3e9a72; --miss: #8a7c76;
  --tile: 44px; --gap: 5px; --mk: 18px; --slot: 54px; --pal: 52px;
  color-scheme: light;
}
* { box-sizing: border-box; }
* { touch-action: manipulation; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif; color: var(--ink);
  background: radial-gradient(ellipse 110% 55% at 50% 0%, var(--bg-hi), transparent 70%), var(--bg);
  overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.app {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--sg-corner-top) - 2px) 8px calc(env(safe-area-inset-bottom, 0px) + 8px);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  --mk-right: #f2b246; --mk-near: #8fd0ff; --mk-none: rgba(255, 255, 255, 0.25);
}
.app[data-theme="brass"] { --cell: #fff3d2; }
.app[data-theme="mint"] { --cell: #eefaf4; }
.app[data-theme="copper"] { --cell: #ffeee2; }
.app[data-theme="midnight"] { --cell: #e9eeff; }
.app[data-theme="gold"] { --cell: #fff6cf; }
.app[data-theme="rose"] { --cell: #ffedf3; }

/* ---- top bar ---- */
.bar { width: 100%; max-width: 520px; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; }
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 16px;
  background: rgba(255, 255, 255, 0.14); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { transform: scale(0.94); }
.switch { justify-self: center; display: flex; padding: 4px; gap: 4px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); min-width: 0; }
.sw {
  min-height: 44px; min-width: 92px; padding: 2px 14px 0; border: 0; border-radius: 999px; background: transparent;
  font-weight: 800; font-size: 17px; line-height: 1; color: var(--ink-soft); cursor: pointer; position: relative;
  -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.sw[aria-selected="true"] { background: var(--cell); color: var(--sheet-ink); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.sw .dot { position: absolute; top: 5px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--win); box-shadow: 0 0 0 2px #fff; }
.sw .dot.x { background: var(--miss); }

/* ---- the line under the bar, and the cat in the corner ---- */
.info { width: 100%; max-width: 520px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-height: 68px; padding: 0 4px; }
.sub { margin: 0 0 6px; font-weight: 800; font-size: 16px; line-height: 1.2; color: var(--ink-soft); min-width: 0; }
.sub b { color: var(--ink); }
.sub .tag { display: inline-block; margin-left: 6px; padding: 1px 8px 0; border-radius: 999px; background: #e9d3f2; color: #5c2f7a; font-size: 13px; }
.buddy { position: relative; display: flex; align-items: flex-end; gap: 6px; flex: none; }
.buddy-cat { width: 66px; height: 76px; margin-bottom: -6px; transform-origin: 50% 100%; }
.buddy-cat svg { width: 100%; height: 100%; display: block; }
.bubble {
  position: absolute; right: calc(100% + 2px); top: 0; z-index: 2; width: max-content; max-width: min(230px, calc(100vw - 110px));
  margin: 0; padding: 6px 11px 4px; border-radius: 14px;
  background: #fff; color: var(--sheet-ink); font-weight: 700; font-size: 14px; line-height: 1.2;
  box-shadow: 0 3px 10px -4px rgba(0, 0, 0, 0.5); opacity: 0; transform: translateY(6px) scale(0.9);
  transition: opacity 0.18s, transform 0.18s; pointer-events: none;
}
.bubble::after { content: ""; position: absolute; right: -6px; top: 12px; border: 7px solid transparent; border-left-color: #fff; border-right: 0; }
.bubble.on { opacity: 1; transform: none; }
.buddy-cat.hop { animation: hop 0.5s ease-out; }
.buddy-cat.wiggle { animation: wiggle 0.45s ease-in-out; }
.buddy-cat.cheer { animation: cheer 0.9s ease-out 2; }
.buddy-cat.sad { animation: sad 0.8s ease-out forwards; }
.buddy-cat.sad-still { transform: rotate(-8deg) translateY(4px); filter: saturate(0.6); }
@keyframes hop { 0%, 100% { transform: none; } 35% { transform: translateY(-12px) scale(1.04, 0.96); } 60% { transform: translateY(0) scale(1.05, 0.95); } }
@keyframes wiggle { 0%, 100% { transform: none; } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes cheer { 0%, 100% { transform: none; } 30% { transform: translateY(-18px) rotate(-6deg); } 60% { transform: translateY(-6px) rotate(6deg); } }
@keyframes sad { to { transform: rotate(-8deg) translateY(4px); filter: saturate(0.6); } }

/* ---- the board: one row per guess, the markers beside it ---- */
.stage { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.board { display: grid; gap: var(--gap); }
.row { display: flex; align-items: center; gap: 10px; }
.cells { display: grid; grid-auto-flow: column; grid-auto-columns: var(--tile); gap: var(--gap); }
.cell {
  width: var(--tile); height: var(--tile); display: grid; place-items: center; border-radius: calc(var(--tile) * 0.24);
  background: var(--hole); border: 2px dashed rgba(255, 255, 255, 0.16);
}
.cell.full { background: var(--cell); border: 2px solid rgba(0, 0, 0, 0.18); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.cell svg { width: 82%; height: 82%; display: block; }
.marks { display: grid; grid-template-columns: repeat(var(--mcols, 2), var(--mk)); grid-auto-rows: var(--mk); gap: 2px; align-content: center; min-height: var(--tile); }
.marks svg { width: var(--mk); height: var(--mk); display: block; }
.marks.new svg { animation: markin 0.35s ease-out both; }
.row.bounce .cell.full { animation: bounce 0.5s ease-out both; }
.legend { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-weight: 700; font-size: 13px; line-height: 1.2; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.legend svg { width: 17px; height: 17px; flex: none; }
@keyframes markin { 0% { transform: scale(0.2); opacity: 0; } 70% { transform: scale(1.25); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: none; } 40% { transform: translateY(-12px); } 70% { transform: translateY(2px); } }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.1); } 100% { transform: none; } }

/* ---- messages ---- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 118px); z-index: 5; margin: 0; max-width: calc(100% - 32px);
  padding: 9px 16px 7px; border-radius: 14px; background: #fff; color: var(--sheet-ink); font-weight: 800; font-size: 16px; line-height: 1.2;
  text-align: center; transform: translate(-50%, -8px); opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- the guess in the making: the slots, the cat things to tap, the buttons ---- */
.panel { width: 100%; max-width: 520px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 4px; }
.panel[hidden] { display: none; }
.entry-row { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.entry { display: grid; grid-auto-flow: column; grid-auto-columns: var(--slot); gap: 5px; justify-content: center; }
.entry.shake { animation: shake 0.42s ease-in-out; }
.slot {
  width: var(--slot); height: var(--slot); display: grid; place-items: center; padding: 0; border-radius: 14px; cursor: pointer;
  background: var(--hole); border: 2.5px dashed rgba(255, 255, 255, 0.4); -webkit-tap-highlight-color: transparent;
}
.slot.full { background: var(--cell); border: 2.5px solid rgba(0, 0, 0, 0.2); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); animation: pop 0.12s ease-out; }
.slot svg { width: 84%; height: 84%; display: block; }
.slot:active { transform: scale(0.95); }
.palette { display: grid; grid-template-columns: repeat(var(--pcols, 6), var(--pal)); gap: var(--pgap, 8px); justify-content: center; }
.thing {
  width: var(--pal); height: 46px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--cell); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); -webkit-tap-highlight-color: transparent;
}
.thing svg { width: 38px; height: 38px; display: block; }
.thing.clear { background: rgba(255, 255, 255, 0.16); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.thing.clear svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.thing:active { transform: translateY(2px); box-shadow: none; }
.pill {
  min-height: 48px; padding: 4px 18px 0; border: 0; border-radius: 16px; background: rgba(255, 255, 255, 0.16);
  font-weight: 800; font-size: 18px; cursor: pointer; -webkit-tap-highlight-color: transparent; color: var(--ink);
}
.pill.primary { background: var(--accent); color: var(--accent-ink); }
.pill.guess { flex: none; width: var(--guess-w, 84px); height: var(--slot); padding: 2px 4px 0; }
.pill.primary.wait { background: rgba(242, 178, 70, 0.5); }
.pill:active { transform: scale(0.97); }
.pill[hidden] { display: none; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(5px); } }

/* ---- the finished puzzle: result, the code and the countdown, in the panel's place ---- */
.done {
  width: 100%; max-width: 520px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 12px 8px; border-radius: 22px; background: rgba(255, 255, 255, 0.12); box-shadow: 0 6px 18px -12px rgba(0, 0, 0, 0.6);
}
.done[hidden] { display: none; }
.done-title { margin: 0; font-weight: 800; font-size: 22px; line-height: 1.15; text-align: center; }
.done-code { display: flex; gap: 6px; justify-content: center; }
.done-code span { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: var(--cell); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.done-code svg { width: 84%; height: 84%; display: block; }
.done-next { margin: 0; font-weight: 700; font-size: 16px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.done-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; padding: 4px 0 2px; }

/* ---- sheets (stats, archive, sticker book, results): on the shared light sheet ---- */
.bv-tabs { display: flex; gap: 6px; padding: 4px; border-radius: 999px; background: rgba(74, 47, 34, 0.09); margin: 0 0 6px; }
.bv-tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 999px; background: transparent; font-weight: 800; font-size: 16px; cursor: pointer; color: var(--sheet-soft); }
.bv-tabs button[aria-selected="true"] { background: #fff; color: var(--sheet-ink); box-shadow: 0 2px 0 rgba(74, 47, 34, 0.14); }
.bv-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 6px; }
.bv-num { text-align: center; }
.bv-num b { display: block; font-size: 30px; line-height: 1.05; }
.bv-num span { display: block; font-size: 13px; font-weight: 700; line-height: 1.15; color: var(--sheet-soft); }
.bv-h { margin: 8px 0 2px; font-weight: 800; font-size: 17px; }
.bv-dist { display: grid; gap: 5px; }
.bv-bar { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; }
.bv-bar i {
  display: block; min-width: 28px; padding: 2px 8px 0; border-radius: 6px; background: var(--miss); color: #fff; text-align: right;
  font-style: normal; line-height: 22px; transition: width 0.4s;
}
.bv-bar.me i { background: var(--win); }
.bv-note { margin: 6px 0 0; font-weight: 700; font-size: 15px; line-height: 1.35; color: var(--sheet-soft); }
.bv-fresh { margin: 0 0 6px; font-weight: 800; font-size: 15px; line-height: 1.3; color: var(--accent-dark); }
.bv-next { margin: 10px 0 0; text-align: center; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; }
.bv-share { width: 100%; min-height: 50px; margin-top: 8px; border: 0; border-radius: 16px; background: #2a3558; color: #fff; font-weight: 800; font-size: 18px; cursor: pointer; }
.bv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bv-day {
  width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 14px 4px;
  border: 1px solid rgba(74, 47, 34, 0.18); border-radius: 14px; background: #fff; text-align: left; cursor: pointer; font-weight: 800; font-size: 16px;
}
.bv-day small { display: block; font-weight: 700; font-size: 13px; color: var(--sheet-soft); }
.bv-day .chip { flex: none; padding: 3px 10px 1px; border-radius: 999px; font-size: 14px; background: rgba(74, 47, 34, 0.08); }
.bv-day .chip.win { background: var(--win); color: #fff; }
.bv-day .chip.lose { background: var(--miss); color: #fff; }
.bv-day .chip.go { background: #2a3558; color: #fff; }
.bv-day:disabled { cursor: default; background: rgba(255, 255, 255, 0.5); }
.bv-more { min-height: 48px; border: 0; border-radius: 14px; background: rgba(74, 47, 34, 0.09); font-weight: 800; font-size: 16px; cursor: pointer; }
.bv-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.bv-sticker {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 104px; padding: 4px;
  border: 2px solid transparent; border-radius: 16px; background: rgba(255, 255, 255, 0.7); cursor: pointer;
}
.bv-sticker svg { width: 84px; height: auto; display: block; }
.bv-sticker small { font-weight: 700; font-size: 12px; line-height: 1.1; color: var(--sheet-soft); text-align: center; }
.bv-sticker[aria-pressed="true"] { border-color: #2a3558; background: #fff; }
.bv-sticker.locked { cursor: default; background: rgba(74, 47, 34, 0.06); }
.bv-sticker.locked .q { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; border: 2px dashed rgba(74, 47, 34, 0.3); font-weight: 800; font-size: 26px; color: rgba(74, 47, 34, 0.4); }
.bv-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.bv-theme { min-height: 84px; display: grid; gap: 4px; justify-items: center; align-content: center; padding: 8px 4px 4px; border: 2px solid transparent; border-radius: 14px; background: rgba(255, 255, 255, 0.7); cursor: pointer; font-weight: 800; font-size: 14px; }
.bv-theme svg { width: 46px; height: 46px; display: block; }
.bv-theme[aria-pressed="true"] { border-color: #2a3558; background: #fff; }
.bv-theme:disabled { cursor: default; opacity: 0.55; }
.bv-paws { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 800; }
.bv-ex { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; }
.bv-ex .cells { --tile: 40px; --gap: 4px; }
.bv-ex .marks { --mk: 17px; }
.bv-ex .cell.full { background: #fff; border-color: rgba(74, 47, 34, 0.2); }
.bv-ach { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bv-ach li { display: flex; gap: 10px; align-items: center; padding: 8px 12px 6px; border-radius: 14px; background: rgba(255, 255, 255, 0.7); font-weight: 700; font-size: 15px; line-height: 1.25; }
.bv-ach li b { display: block; font-size: 16px; }
.bv-ach li.no { opacity: 0.55; }
.bv-ach .medal { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #f4c44e; color: #6b4a0c; font-weight: 800; }
.bv-ach li.no .medal { background: rgba(74, 47, 34, 0.14); color: transparent; }

/* ---- the title screen's colors (the layout is shared/mainmenu.js) ---- */
#mm {
  --sg-bg: radial-gradient(ellipse 100% 70% at 50% 25%, var(--bg-hi), transparent 75%), var(--bg);
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: #ffd479; --sg-title-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  --sg-accent: var(--accent); --sg-accent-ink: var(--accent-ink);
  --sg-card: #fff8ee; --sg-card-ink: var(--sheet-ink); --sg-line: rgba(255, 246, 232, 0.25);
}
#mm .bv-title-art { width: 167px; height: 150px; }
#mm .bv-title-art svg { display: block; width: 100%; height: 100%; }
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--sheet-ink); --sg-accent: #2a3558; --sg-accent-ink: #fff; --sg-ink-soft: var(--sheet-soft); }

@media (max-height: 700px) {
  .info { min-height: 52px; }
  .buddy-cat { width: 52px; height: 60px; }
  .toast { top: calc(env(safe-area-inset-top, 0px) + 100px); }
}
@media (prefers-reduced-motion: reduce) {
  .marks.new svg, .row.bounce .cell.full, .slot.full, .buddy-cat.hop, .buddy-cat.wiggle, .buddy-cat.cheer { animation: none; }
  .entry.shake { animation: none; box-shadow: 0 0 0 3px rgba(255, 120, 100, 0.7); border-radius: 12px; }
  .buddy-cat.sad { animation: none; transform: rotate(-4deg); }
  .bubble, .toast, .bv-bar i { transition: none; }
}

/* the crack: the safe's door over the guesses, swinging open on its left hinge */
.crack-door { position: fixed; z-index: 30; pointer-events: none; transform-origin: 0 50%; backface-visibility: hidden; }
.crack-door svg { display: block; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3)); }
