/* Meowdoku — all styling via classes (CSP forbids inline styles). */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1a1526; color: #efe9f5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none;
}
#app {
  height: 100%; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
}
#bar h1 { font-size: 20px; margin: 0; letter-spacing: .5px; font-weight: 800; }
#bar h1 span { color: #ffb74d; }
#stats { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
#lives { letter-spacing: 1px; font-size: 15px; }
#timer { opacity: .8; }
#solved { opacity: .8; }
#newBtn {
  border: 0; border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 700;
  background: #6d4aff; color: #fff; cursor: pointer;
}
#newBtn:active { transform: scale(.96); }
#hintBtn {
  border: 0; border-radius: 999px; padding: 8px 12px; font-size: 15px; line-height: 1;
  background: #3a2f55; color: #fff; cursor: pointer;
}
#hintBtn:active { transform: scale(.96); }

#toast {
  position: fixed; left: 50%; top: 58px; transform: translateX(-50%);
  background: #3a2f55; color: #fff; border: 1px solid #5a4a80;
  padding: 9px 16px; border-radius: 999px; font-size: 13.5px; max-width: 88vw; text-align: center;
  z-index: 8; box-shadow: 0 8px 24px rgba(0,0,0,.4); transition: opacity .25s;
}
#toast.hidden { opacity: 0; pointer-events: none; }

/* hint spotlight: dim the whole board, then light up the cells that PROVE the
   deduction (the glowing row/column/colour and where the trapped colour can go),
   and ring the target square. */
#board.hinting .cell { opacity: .15; transition: opacity .2s; }
#board.hinting .cell.spot { opacity: 1; }
/* where the confined colour(s)/line(s) can still go — a bright inner frame */
.cell.spota { box-shadow: inset 0 0 0 3px rgba(255,255,255,.95); z-index: 1; }
/* the target square: a pulsing ring */
.cell.hintpulse::before {
  content: ""; position: absolute; inset: 2px; border-radius: 4px; z-index: 2;
  box-shadow: 0 0 0 3px #fff, 0 0 14px 4px #fff;
  animation: hintpulse 1s ease-in-out infinite;
}
@keyframes hintpulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }

#boardWrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 6px; }

#board {
  /* Inset from the screen edges so Android's edge-swipe (back/forward) gesture
     isn't triggered while dragging near the sides. The -56px guarantees a ~28px
     dead-zone each side regardless of screen width. */
  width: min(100vw - 56px, 68vh); aspect-ratio: 1 / 1;
  display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: repeat(12, 1fr);
  border: 3px solid #0e0a17; border-radius: 8px; overflow: hidden;
  touch-action: none; -webkit-touch-callout: none;
  font-size: calc(min(96vw, 68vh) / 20);
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
/* board size varies per puzzle — driven by data-n (CSP-safe, no inline styles) */
#board[data-n="8"]  { grid-template-columns: repeat(8, 1fr);  grid-template-rows: repeat(8, 1fr);  font-size: calc(min(96vw, 68vh) / 13); }
#board[data-n="9"]  { grid-template-columns: repeat(9, 1fr);  grid-template-rows: repeat(9, 1fr);  font-size: calc(min(96vw, 68vh) / 15); }
#board[data-n="10"] { grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); font-size: calc(min(96vw, 68vh) / 17); }
#board[data-n="11"] { grid-template-columns: repeat(11, 1fr); grid-template-rows: repeat(11, 1fr); font-size: calc(min(96vw, 68vh) / 18); }
#board[data-n="12"] { grid-template-columns: repeat(12, 1fr); grid-template-rows: repeat(12, 1fr); font-size: calc(min(96vw, 68vh) / 20); }

.cell {
  position: relative; display: flex; align-items: center; justify-content: center;
  border: 0.5px solid rgba(0,0,0,.18);
  cursor: pointer;
}
/* region-boundary edges: thick dark walls between different colours */
.cell.bt { border-top: 2.5px solid #0e0a17; }
.cell.bb { border-bottom: 2.5px solid #0e0a17; }
.cell.bl { border-left: 2.5px solid #0e0a17; }
.cell.br { border-right: 2.5px solid #0e0a17; }

/* marks */
.cell.mark::after {
  content: "✕"; font-size: .62em; font-weight: 800; color: rgba(20,10,30,.5);
}
.cell.cat::after { content: "🐱"; font-size: .92em; line-height: 1; }
.cell.cat { filter: saturate(1.15); }
.cell.wrong { animation: wrong .45s ease; }
@keyframes wrong {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(255,0,0,0); }
  30% { box-shadow: inset 0 0 0 4px rgba(255,40,40,.95); }
}
.cell.pop::after { animation: pop .28s ease; }
@keyframes pop { 0% { transform: scale(.4); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* 12 region colours */
.r0  { background: #e57373; }
.r1  { background: #f06292; }
.r2  { background: #ba68c8; }
.r3  { background: #9575cd; }
.r4  { background: #7986cb; }
.r5  { background: #64b5f6; }
.r6  { background: #4dd0e1; }
.r7  { background: #4db6ac; }
.r8  { background: #81c784; }
.r9  { background: #cddc6b; }
.r10 { background: #ffd54f; }
.r11 { background: #ffb74d; }

#help {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); font-size: 12.5px; opacity: .8;
}
#help b { color: #ffb74d; font-weight: 700; }

/* overlays */
#overlay, #gen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10,7,18,.72); backdrop-filter: blur(4px); z-index: 10;
}
#overlay.hidden, #gen.hidden { display: none; }
#ovCard {
  background: #2a2140; border: 1px solid #43356a; border-radius: 18px;
  padding: 26px 30px; text-align: center; max-width: 300px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
#ovEmoji { font-size: 52px; }
#ovCard h2 { margin: 8px 0 6px; font-size: 24px; }
#ovCard p { margin: 0 0 18px; opacity: .85; font-size: 15px; line-height: 1.4; }
#ovBtn {
  border: 0; border-radius: 999px; padding: 12px 28px; font-size: 16px; font-weight: 800;
  background: #6d4aff; color: #fff; cursor: pointer;
}
#ovBtn:active { transform: scale(.96); }
.genInner {
  background: #2a2140; border: 1px solid #43356a; border-radius: 14px;
  padding: 18px 24px; font-size: 16px;
}
