/* ── Grid hint (matches sudoku-solver.css) ─────────────────────────────────── */
.grid-hint {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none; z-index: 5;
    transition: opacity .4s ease;
}
.grid-hint.hidden { opacity: 0; pointer-events: none; }
.grid-hint span {
    font-size: 14px; color: var(--muted); text-align: center;
    line-height: 1.6; padding: 20px;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(4px); border-radius: 10px;
}

/* ── KenKen Grid ───────────────────────────────────────────────────────────── */
.kenken-grid {
    width: min(94vw, 480px);
    aspect-ratio: 1;
    display: grid;
    border: 2.5px solid var(--accent);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 20px var(--accent-glow), 0 8px 32px rgba(0,0,0,.06);
    background: var(--border);
    gap: 1px;
    position: relative;
    container-type: inline-size;
}
.kenken-grid.size-4 { grid-template-columns: repeat(4,1fr); grid-template-rows: repeat(4,1fr); }
.kenken-grid.size-6 { grid-template-columns: repeat(6,1fr); grid-template-rows: repeat(6,1fr); }

/* ── KenKen cells ─────────────────────────────────────────────────────────── */
.kk-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 9cqi;
    font-weight: 600;
    cursor: pointer;
    transition: background .1s;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    color: var(--fg);
    -webkit-tap-highlight-color: transparent;
    min-height: 0; min-width: 0; overflow: hidden;
}
.kk-cell:hover      { background: var(--card-hover); }
.kk-cell.user       { color: var(--accent); }
.kk-cell.solver-fill{ color: var(--success); }
.kk-cell.error-cell { color: var(--error) !important; background: var(--error-bg) !important; }
.kk-cell.selected   { background: var(--accent-glow) !important; box-shadow: inset 0 0 0 2px var(--accent); z-index: 2; }
.kk-cell.highlighted{ background: rgba(194,65,12,.04); }
.kk-cell.same-number{ background: rgba(194,65,12,.08); }
.kk-cell.solved-cell{ color: var(--success) !important; animation: cellPop .3s cubic-bezier(.34,1.56,.64,1); }

/* Cage colors */
.kk-cell[data-cage="0"]  { --cage-c: rgba(59,130,246,.12); }
.kk-cell[data-cage="1"]  { --cage-c: rgba(16,185,129,.12); }
.kk-cell[data-cage="2"]  { --cage-c: rgba(245,158,11,.12); }
.kk-cell[data-cage="3"]  { --cage-c: rgba(239,68,68,.10);  }
.kk-cell[data-cage="4"]  { --cage-c: rgba(168,85,247,.11); }
.kk-cell[data-cage="5"]  { --cage-c: rgba(20,184,166,.12); }
.kk-cell[data-cage="6"]  { --cage-c: rgba(249,115,22,.11); }
.kk-cell[data-cage="7"]  { --cage-c: rgba(99,102,241,.11); }
.kk-cell[data-cage="8"]  { --cage-c: rgba(34,197,94,.11);  }
.kk-cell[data-cage="9"]  { --cage-c: rgba(251,191,36,.12); }
.kk-cell[data-cage="10"] { --cage-c: rgba(59,130,246,.12); }
.kk-cell[data-cage="11"] { --cage-c: rgba(16,185,129,.12); }
.kk-cell[data-cage="12"] { --cage-c: rgba(245,158,11,.12); }
.kk-cell[data-cage="13"] { --cage-c: rgba(239,68,68,.10);  }
.kk-cell[data-cage="14"] { --cage-c: rgba(168,85,247,.11); }
.kk-cell[data-cage="15"] { --cage-c: rgba(20,184,166,.12); }
.kk-cell[data-cage="16"] { --cage-c: rgba(249,115,22,.11); }

.kk-cell[data-cage] { background: var(--cage-c, var(--card)); }
.kk-cell[data-cage].selected   { background: var(--accent-glow) !important; }
.kk-cell[data-cage].highlighted{ background: color-mix(in srgb, var(--cage-c, transparent), rgba(194,65,12,.06)); }

/* Cage borders */
.kk-cell.cage-border-top    { border-top:    2px solid var(--fg); }
.kk-cell.cage-border-right  { border-right:  2px solid var(--fg) !important; }
.kk-cell.cage-border-bottom { border-bottom: 2px solid var(--fg) !important; }
.kk-cell.cage-border-left   { border-left:   2px solid var(--fg); }

/* Operation label */
.cage-op {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 1.8cqi;
    font-weight: 700;
    color: var(--fg);
    opacity: .72;
    line-height: 1;
    pointer-events: none;
    z-index: 3;
    white-space: nowrap;
}

@keyframes cellPop {
    0%  { transform: scale(1); }
    50% { transform: scale(1.2); }
    100%{ transform: scale(1); }
}

@media (max-width: 480px) {
    .kenken-grid { width: min(96vw, 420px); }
}

/* Custom puzzle editor */
.editor-toolbar{display:flex;gap:.5rem;flex-wrap:wrap;justify-content:center;padding:.75rem;margin:.75rem auto;border:1.5px dashed var(--border);border-radius:10px;max-width:600px;}
.kk-cell.edit-uncaged{background:var(--card);}
.kk-cell.edit-selected{background:var(--accent)!important;color:#fff!important;outline:2px solid var(--accent);}
