           (fn [{:keys [button state col row] :as click}]
             (log/info "got click" click)
             (if (< col 12)
-              ;; select new tile
-              (do
-                (log/info "selecting tile at" [row col])
-                (when-let [tile (get-in tile-names [row col])]
-                  (reset! current-tile tile)))
+              (if (< row 27)
+                ;; select new tile
+                (do
+                  (log/info "selecting tile at" [row col])
+                  (when-let [tile (get-in tile-names [row col])]
+                    (reset! current-tile tile)))
+                (reset! palette-index (- row 27)))
               ;; draw new tile
               (do
                 (log/info "placing tile at" [row col])

    [156 175 131 255]
    [209 213 201 255]
    [209 213 201 255]
    [209 213 201 255]]])

(def tileset-bw


      

(defn palette
  [palette-index]
  (for [[row line] (map-indexed vector tile-names)
        [col id]   (map-indexed vector line)]
    {:c id :fg [255 255 255] :bg [0 0 0] :x col :y row :palette-index palette-index}))

(def color-table-chars
  (for [[row line] (map-indexed vector color-table)
        [col bg]   (map-indexed vector line)]
    {:c \space :fg [255 255 255] :bg bg :x col :y (+ row 28)}))

(log/info font)
;(log/info "palette" (vec palette))

(defn -main [& _]
  ;; render in background thread
