/* EwrekaGames — Kakuro board (assets/js/solo/kakuro.js). Shell styles: assets/css/solo.css. */
.kk {
  --kk-block: #2b3446; --kk-block-2: #232b3a; --kk-clue: #f4f6fa; --kk-diag: rgba(255, 255, 255, .28);
  --kk-cell: var(--surface); --kk-run: rgba(61, 123, 247, .12); --kk-sel: rgba(255, 107, 74, .2);
  --kk-ok: #7fd9b4; --kk-bad-bg: rgba(229, 72, 77, .14);
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
:root[data-theme="dark"] .kk {
  --kk-block: #0d1118; --kk-block-2: #0a0d13; --kk-clue: #dfe5ee; --kk-diag: rgba(255, 255, 255, .2);
  --kk-cell: var(--surface-3); --kk-run: rgba(91, 143, 249, .16); --kk-sel: rgba(255, 118, 86, .24);
  --kk-ok: #34d399; --kk-bad-bg: rgba(248, 113, 113, .16); --kk-runmix: 26%;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .kk {
    --kk-block: #0d1118; --kk-block-2: #0a0d13; --kk-clue: #dfe5ee; --kk-diag: rgba(255, 255, 255, .2);
    --kk-cell: var(--surface-3); --kk-run: rgba(91, 143, 249, .16); --kk-sel: rgba(255, 118, 86, .24);
    --kk-ok: #34d399; --kk-bad-bg: rgba(248, 113, 113, .16); --kk-runmix: 26%;
  }
}

/* frame + optional zoom (pan by scrolling) */
.kk-frame { position: relative; max-width: 100%; }
.kk-scroll { max-width: 100%; border-radius: 14px; box-shadow: 0 4px 0 var(--kk-block-2), var(--shadow); background: var(--kk-block); }
.kk-frame.zoomed .kk-scroll { overflow: auto; max-height: min(64vh, 520px); max-height: max(220px, min(64vh, 520px, calc(100svh - 330px))); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.kk-under { width: 100%; max-width: 560px; display: flex; align-items: flex-start; gap: 8px; }
.kk-under .kk-help { flex: 1; min-width: 0; }
.kk-zoom { flex: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); box-shadow: var(--press); display: grid; place-items: center; cursor: pointer; touch-action: manipulation; transition: transform .08s, box-shadow .08s; }
.kk-zoom svg { width: 20px; height: 20px; }
.kk-zoom:active { transform: translateY(3px); box-shadow: none; }
.kk-zoom.hidden { display: none; }

.kk-grid {
  --cs: 40px;
  display: grid; grid-template-columns: repeat(var(--kw), var(--cs)); grid-auto-rows: var(--cs);
  gap: 0; padding: 3px; width: max-content; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.kk-row { display: contents; }
.kk-c { position: relative; box-sizing: border-box; }
.kk-b { background: var(--kk-block); }
.kk-clue { background: linear-gradient(to top right, transparent calc(50% - .75px), var(--kk-diag) calc(50% - .75px), var(--kk-diag) calc(50% + .75px), transparent calc(50% + .75px)), var(--kk-block); cursor: pointer; }
.kk-clue span { position: absolute; font-weight: 800; color: var(--kk-clue); font-size: max(9px, calc(var(--cs) * .36)); line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; padding: 1px 2px; border-radius: 4px; transition: color .2s, background-color .2s, opacity .2s; }
.kk-sa { right: 4%; top: 5%; }
.kk-sd { left: 4%; bottom: 4%; }
/* clues of the selected runs: a calm blue pill (coral/red is reserved for mistakes) */
.kk-clue span.act { background: var(--blue); color: #fff; opacity: 1; }
.kk-clue span.ok { color: var(--kk-ok); opacity: .75; }
.kk-clue span.bad { color: #ff8a8d; text-decoration: underline wavy; text-underline-offset: 2px; }
.kk-clue span.act.ok { color: #fff; opacity: 1; }
.kk-clue span.act.bad { background: var(--bad); color: #fff; text-decoration: none; }

.kk-w { background: var(--kk-cell); box-shadow: inset 0 0 0 1px var(--line-2); cursor: pointer; display: grid; place-items: center; transition: background .12s; }
.kk-w.run { background: color-mix(in srgb, var(--kk-cell), var(--blue) var(--kk-runmix, 13%)); }
.kk-w.same .kk-v { color: var(--blue); }
.kk-w.sel { background: color-mix(in srgb, var(--kk-cell), var(--brand) 22%); box-shadow: inset 0 0 0 2px var(--brand); z-index: 1; }
@supports not (background: color-mix(in srgb, red, blue)) {
  .kk-w.run { background: var(--kk-run); }
  .kk-w.sel { background: var(--kk-sel); }
  .kk-w.bad { background: var(--kk-bad-bg); }
}
.kk-v { font-size: calc(var(--cs) * .56); font-weight: 700; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.kk-w.hinted::before { content: ""; position: absolute; top: 3px; right: 3px; width: max(4px, calc(var(--cs) * .13)); height: max(4px, calc(var(--cs) * .13)); border-radius: 50%; background: var(--blue); pointer-events: none; }
.kk-w.bad { background: color-mix(in srgb, var(--kk-cell), var(--bad) 16%); }
.kk-w.bad .kk-v { color: var(--bad); }
.kk-n { position: absolute; inset: 2px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); pointer-events: none; }
.kk-n span { font-size: calc(var(--cs) * .21); line-height: 1; color: var(--blue); font-weight: 600; display: grid; place-items: center; opacity: 0; }
.kk-n span.on { opacity: 1; }
.kk-w:not(.has-notes) .kk-n { display: none; }

/* animations (each triggered once by the action that caused it) */
.kk-w.pop .kk-v { animation: kk-pop .28s var(--spring); }
.kk-w.flash::after { content: ""; position: absolute; inset: 0; border-radius: 4px; background: var(--good); opacity: 0; animation: kk-flash .55s ease-out; pointer-events: none; }
@keyframes kk-pop { 0% { transform: scale(.4); opacity: .2; } 100% { transform: scale(1); opacity: 1; } }
@keyframes kk-flash { 0% { opacity: .45; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.05); } }
.kk.solved .kk-w { cursor: default; }
.kk.solved .kk-v { color: var(--ink); }

/* combination helper */
.kk-help { width: 100%; max-width: 560px; min-height: 64px; display: grid; gap: 6px; align-content: start; }
.kk-hrow { display: flex; align-items: center; gap: 8px; min-height: 29px; flex-wrap: nowrap; }
.kk-dir { width: 22px; height: 22px; flex: none; border-radius: 7px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; }
.kk-dir svg { width: 15px; height: 15px; }
.kk-rs { flex: none; font-size: 13px; font-weight: 700; color: var(--ink); min-width: 74px; white-space: nowrap; }
.kk-hrow.ok .kk-rs { color: var(--good); }
.kk-chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.kk-chip { font-size: 13px; font-weight: 700; letter-spacing: .06em; padding: 3px 7px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink); font-variant-numeric: tabular-nums; }
.kk-chip.off { opacity: .38; text-decoration: line-through; }
.kk-none { font-size: 12px; color: var(--bad); font-weight: 600; align-self: center; }
.kk-hint { margin: 0; font-size: 13px; color: var(--ink-3); text-align: center; align-self: center; }

@media (max-width: 640px) {
  .kk-rs { min-width: 0; font-size: 12px; }
  .kk-chip { font-size: 12px; padding: 2px 5px; }
  .kk-help { min-height: 58px; }
}
/* CLS: the "loading" placeholder takes the room of the first board a visitor gets (easy, 7×7 cells: kakuro.js fit()
   makes the cell floor((width - 6) / 7), at most 54 px) plus the help row, the gap and the number pad under it.
   Other levels differ by a few pixels only. (5.95 rather than 6: an exact multiple of 7 must not round down a pixel.) */
body.solo-page #soloBoard > .loading-box {
  width: min(100%, 384px);
  width: calc(7 * min(54px, round(down, calc((100% - 5.95px) / 7), 1px)) + 6px);
  aspect-ratio: 1; min-height: 0; padding: 0; margin-bottom: 190px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
@media (max-width: 640px) {
  body.solo-page #soloBoard > .loading-box { margin-bottom: 174px; }
}
/* from 700 px fit() also keeps the board inside the window height: cell <= floor((innerHeight - min(top, 220) - 198) / 7),
   at least 30; the board starts at 227 px up to 960 px (top bar layout: 220 counts) and at 181 px from 961 px on
   (no language strip) */
@media (min-width: 700px) {
  body.solo-page #soloBoard > .loading-box { width: calc(7 * min(54px, round(down, calc((100% - 5.95px) / 7), 1px), max(30px, round(down, calc((100vh - 417.95px) / 7), 1px))) + 6px); }
}
@media (min-width: 961px) {
  body.solo-page:not(:has(.langhint)) #soloBoard > .loading-box { width: calc(7 * min(54px, round(down, calc((100% - 5.95px) / 7), 1px), max(30px, round(down, calc((100vh - 378.95px) / 7), 1px))) + 6px); }
}
@media (prefers-reduced-motion: reduce) {
  .kk-w.pop .kk-v, .kk-w.flash::after { animation: none; }
}
