body:has(.picross-game) { margin: 0; background: #fcf8ef; }
.picross-game {
  --ink: #413749;
  --accent: #6d4b7a;
  --mint: #dcece3;
  max-width: 1040px;
  margin: auto;
  padding: 12px 24px 42px;
  color: var(--ink);
  font-family: var(--ui2-font-family);
}
.picross-game * { box-sizing: border-box; }
.picross-game [hidden] { display: none !important; }
.cp-skip { position: fixed; top: -100px; left: 12px; z-index: 10000; background: white; padding: 12px; }
.cp-skip:focus { top: 12px; }
.cp-back { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-size: 14px; }
.cp-intro {
  display: grid;
  grid-template-columns: 1.13fr 1fr;
  align-items: center;
  gap: 28px;
  padding: 16px;
  border: 1px solid #e8d9c8;
  border-radius: 25px;
  background: #fff9ef;
}
.cp-intro img, .cp-results img { width: 100%; height: auto; display: block; border-radius: 18px; }
.cp-copy { padding: 10px; }
.cp-copy h1 { font-size: clamp(29px, 4vw, 47px); letter-spacing: -.035em; line-height: 1.15; margin: 0 0 12px; }
.cp-copy p { margin: 0 0 14px; line-height: 1.55; }
.cp-rule { border-inline-start: 3px solid #bd9bd0; padding: 6px 0 6px 10px; font-size: 14px; }
.picross-game button {
  min-height: 44px;
  border: 1px solid #cdb9ce;
  border-radius: 12px;
  background: #fffaf5;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.picross-game button:focus-visible, .cp-back:focus-visible, .cp-help summary:focus-visible { outline: 2px solid #674679; outline-offset: 2px; }
.picross-game button:disabled { opacity: .48; cursor: default; }
.picross-game .cp-primary { background: #ebcadd; border-color: #bb9cbe; box-shadow: 0 3px 0 #bd9bbd; padding: 7px 12px; }
.cp-intro .cp-primary { display: flex; justify-content: space-between; width: 100%; }
.cp-copy #cp-continue { width: 100%; margin-top: 8px; }
.cp-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.cp-heading h2 { font-size: clamp(21px, 4vw, 29px); line-height: 1.15; margin: 0; }
.cp-level { color: var(--accent); margin: 0 0 3px; font-size: 12px; font-weight: 800; }
.cp-heading ol { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0; }
.cp-heading li { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: #eee2ee; color: var(--accent); font-size: 11px; }
.cp-heading li[aria-current] { background: var(--accent); color: white; }
.cp-workspace { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 20px; align-items: start; max-width: 880px; }
.cp-board { background: var(--mint); border: 1px solid #bacfc2; border-radius: 22px; padding: 14px; box-shadow: 0 4px 0 #c9dfd2; }
#cp-grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; background: #fff5e5; border-radius: 10px; }
#cp-grid .cp-gutter { width: 46px; }
#cp-grid th, #cp-grid td { padding: 0; }
#cp-grid th { color: #4b3757; background: #efe2f1; font-weight: 800; line-height: 1.05; font-size: 12px; }
#cp-grid .cp-corner { background: #efe2f1; border-radius: 10px 0 0 0; }
#cp-grid thead th:last-child { border-radius: 0 10px 0 0; }
#cp-grid tbody tr:last-child th { border-radius: 0 0 0 10px; }
.cp-numbers { display: flex; align-items: center; justify-content: flex-end; gap: 3px; padding: 2px 4px; }
.cp-numbers span { min-width: 7px; text-align: center; }
#cp-grid thead th { vertical-align: bottom; border-inline-start: 1px solid #d4bbd4; }
#cp-grid thead .cp-numbers { flex-direction: column; padding: 4px 0; }
#cp-grid tbody th { border-top: 1px solid #d4bbd4; }
.picross-game .cp-cell {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 44px;
  aspect-ratio: 1;
  border: 0;
  border-inline-start: 1px solid #d7c4ac;
  border-top: 1px solid #d7c4ac;
  border-radius: 0;
  background: #fff9ee;
  padding: 0;
}
.cp-cell:focus-visible { position: relative; z-index: 1; outline-offset: -3px !important; }
.picross-game .cp-cell:hover { background: #faeee8; }
.cp-cell i, .cp-mini-cookie { display: block; width: 68%; max-width: 38px; aspect-ratio: 1; border-radius: 50%; }
.cp-cell[data-state="1"] i, .cp-mini-cookie {
  background: radial-gradient(circle at 35% 35%, #8c5471 0 7%, transparent 9%),
    radial-gradient(circle at 67% 43%, #8c5471 0 7%, transparent 9%),
    radial-gradient(circle at 50% 70%, #8c5471 0 7%, transparent 9%), #ecc0cc;
  border: 1px solid #b68298;
  box-shadow: inset 0 2px 0 #ffffff95, 0 2px 0 #d0a7aa;
}
.cp-cell[data-state="-1"] i { display: grid; place-items: center; }
.cp-cell[data-state="-1"] i::before { content: "×"; color: #756481; font: 800 23px/1 system-ui, sans-serif; }
#cp-grid.is-solved .cp-cell[data-state="1"] i { animation: cp-pop .28s ease-out; background-color: #f4d99e; border-color: #c19b52; }
#cp-grid.is-solved .cp-cell[data-state="-1"] i { opacity: .24; }
@keyframes cp-pop { 45% { transform: scale(1.17); } }
.cp-modes, .cp-actions { display: flex; gap: 6px; margin-top: 8px; }
.cp-modes button { flex: 1; display: flex; gap: 7px; align-items: center; justify-content: center; padding: 3px; }
.cp-modes button[aria-pressed="true"] { background: #ebcadd; border-color: #906c9e; box-shadow: inset 0 0 0 1px #906c9e; }
.cp-mini-cookie { width: 18px; flex: 0 0 18px; }
.cp-actions button { flex: 1; padding: 3px; }
.cp-actions #cp-next { flex: 1.4; }
.cp-message { margin: 8px 0 0; line-height: 1.25; min-height: 1.3em; text-align: center; font-size: 13px; color: #584361; }
.cp-help { border: 1px solid #e4d5bf; border-radius: 16px; padding: 0 14px; background: #fff9ef; }
.cp-help summary { min-height: 44px; padding: 11px 0; font-weight: 750; cursor: pointer; }
.cp-help p { margin: 0 0 11px; font-size: 14px; line-height: 1.55; }
.cp-results { width: min(100%, 530px); margin: auto; background: #fff9ef; padding: 16px; border: 1px solid #e8d9c8; border-radius: 24px; }
.cp-results h2 { margin: 13px 0; }
@media (max-width: 700px) {
  .picross-game { padding: 8px 10px 30px; }
  .picross-game .cp-back { min-height: 44px; }
  .cp-intro { grid-template-columns: 1fr; gap: 11px; padding: 11px; }
  .cp-copy { padding: 3px; }
  .cp-heading ol { display: grid; grid-template-columns: repeat(5, auto); }
  .cp-copy p { font-size: 14px; }
  .cp-workspace { grid-template-columns: 1fr; max-width: 480px; margin: auto; gap: 12px; }
  .cp-board { padding: 7px; }
  #cp-grid .cp-gutter { width: 38px; }
  .cp-numbers { gap: 3px; padding-inline: 3px; }
  .cp-modes, .cp-actions { font-size: 14px; }
}
@media (max-width: 360px) {
  .picross-game { padding-inline: 6px; }
  .cp-board { padding: 3px; }
  .cp-heading li { width: 19px; height: 19px; }
  #cp-grid .cp-gutter { width: 34px; }
  #cp-grid th { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  #cp-grid.is-solved .cp-cell[data-state="1"] i { animation: none; }
}
