#board_show {
  margin-top: 10px;

  #play_area {
    #game_board {
      background-color: #EEE;
      border: 5px solid #333;
      display: inline-block;

      .cell_row {
        display: flex;
        justify-content: center;
      }

      .cell {
        border-radius: 0;
        cursor: pointer;
      }

      .draggable_cells {
        text-align: center;
        overflow: visible;
        width: 100%;
        position: relative;
        .draggable_cell {
          float: none;
          display: inline-block;
          cursor: pointer;
          z-index: 99;
        }
      }

      hr {
        border: none;
        margin: 5px;
      }
    }
  }
}

#cell_sets,
#new_board,
#edit_board,
#cell_set {
  flex: 1 1 auto;
  min-width: 0;
  background: #f4f7fa;
  color: #263746;
}

.boards_container {
  box-sizing: border-box;
  width: min(1100px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 52px;
}

.boards_header,
.boards_catalog_heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;

  p {
    max-width: 650px;
    margin: 0;
    color: #647181;
    font-size: 16px;
    line-height: 1.5;
  }
}

.boards_header h1 {
  margin: 5px 0 8px;
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 400;
  line-height: 1.1;
}

.boards_eyebrow {
  color: #238cb9;
  font: 13px 'Acme';
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.boards_primary_action,
.boards_secondary_action {
  box-sizing: border-box;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid #1686bb;
  border-radius: 8px;
  background: var(--btn-primary);
  color: #102f40;
  cursor: pointer;
  font: 16px 'Acme';
  box-shadow: 0 2px 5px rgba(25, 48, 68, 0.14);

  &:hover {
    background: #56c6f7;
  }
}

.boards_secondary_action {
  border-color: #aebdca;
  background: #fff;
  color: #34475a;

  &:hover {
    border-color: #7891a3;
    background: #eef5f8;
    color: #176b96;
  }
}

#cell_sets :is(a, button, input, select, summary):focus-visible,
#new_board :is(a, input, select):focus-visible,
#edit_board :is(a, button, input, [tabindex]):focus-visible,
#cell_set :is(a, input, select, [tabindex]):focus-visible {
  outline: 2px solid #176b96;
  outline-offset: 3px;
}

.boards_catalog_heading {
  margin-bottom: 16px;

  h2 {
    margin: 0;
    font-size: 25px;
    font-weight: 400;
  }

  p {
    margin-top: 6px;
    font-size: 14px;
  }
}

.boards_sort_form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.boards_sort_field {
  flex: 1 1 auto;
}

.board_cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
}

.board_card,
.boards_empty {
  min-width: 0;
  border: 1px solid #d5dee6;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(25, 48, 68, 0.07);
}

.board_card_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid #dce4ea;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(110deg, #f8fbfd, #edf4f7);

  h3 {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font: 23px/1.2 'Acme';
  }

  a {
    color: #263746;

    &:hover {
      color: #176b96;
      text-decoration: underline;
    }
  }
}

.board_status {
  flex: none;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.board_status_active {
  background: #eaf4d7;
  color: #496c16;
}

.board_status_inactive {
  background: #e5ebf0;
  color: #526171;
}

.board_stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid #e1e7ec;

  div {
    min-width: 0;
    padding: 16px;
    border-right: 1px solid #e1e7ec;

    &:last-child {
      border-right: 0;
    }
  }

  dt {
    margin-bottom: 7px;
    color: #647181;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  dd {
    margin: 0;
    font: 23px/1.2 'Acme';
  }
}

.board_breakdown {
  padding: 0 20px;

  summary {
    padding: 15px 0;
    color: #176b96;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
  }

  dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 20px;
    margin: 0 0 16px;
  }

  div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 0;
    border-top: 1px solid #e1e7ec;
    font-size: 13px;
  }

  dt {
    color: #647181;
  }

  dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }
}

.board_card_footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid #e1e7ec;
}

.board_created {
  color: #647181;
  font-size: 12px;
}

.board_admin_actions {
  display: flex;
  gap: 7px;

  a,
  button {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 34px;
    padding: 5px 10px;
    border: 1px solid #b7c4ce;
    border-radius: 6px;
    background: #fff;
    color: #526171;
    cursor: pointer;
    font: 13px Arial, sans-serif;

    &:hover {
      border-color: #7891a3;
      background: #eef5f8;
      color: #176b96;
    }
  }

  .board_delete {
    color: #a43343;

    &:hover {
      border-color: #c97984;
      background: #fff3f4;
      color: #8e2635;
    }
  }
}

.boards_empty {
  padding: 32px;
  text-align: center;

  h3 {
    margin: 0 0 8px;
    font: 25px 'Acme';
  }

  p {
    margin: 0;
    color: #647181;
    line-height: 1.5;
  }
}

.board_form_panel {
  box-sizing: border-box;
  max-width: 640px;
  padding: 28px;
  border: 1px solid #d5dee6;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(25, 48, 68, 0.07);

  #error_explanation {
    margin: 0 0 24px;
    padding: 16px;
    border: 1px solid #e5bbc2;
    border-radius: 8px;
    background: #fff3f4;
    color: #8e2635;
    font-size: 14px;

    h2 {
      margin: 0 0 8px;
      font-size: 18px;
      line-height: 1.4;
      text-decoration: none;
    }

    ul {
      margin: 0;
      padding-left: 20px;
      line-height: 1.5;
    }
  }

  .field_with_errors {
    display: block;
    padding: 0;
    background: transparent;

    input,
    select {
      border-color: #b24a5a;
    }
  }
}

.board_form_heading {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e1e7ec;

  h2 {
    margin: 0 0 6px;
    font-size: 25px;
    font-weight: 400;
  }

  p {
    margin: 0;
    color: #647181;
    font-size: 14px;
    line-height: 1.5;
  }
}

.board_form_field {
  min-width: 0;

  label {
    display: block;
    margin-bottom: 8px;
    color: #526171;
    font-size: 13px;
    font-weight: 700;
  }

  input[type='text'],
  select {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #b7c4ce;
    border-radius: 8px;
    background: #fff;
    color: #263746;
    font: 16px Arial, sans-serif;
  }

  select {
    appearance: none;
    padding-right: 42px;
    background-image: url("/assets/select-chevron-f483c4ca.svg");
    background-position: right 14px center;
    background-size: 14px 14px;
    background-repeat: no-repeat;
  }
}

@media (forced-colors: active) {
  .board_form_field select {
    appearance: auto;
    padding-right: 12px;
    background-image: none;
  }
}

.board_form_dimensions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.board_field_hint {
  margin: 8px 0 0;
  color: #647181;
  font-size: 13px;
  line-height: 1.4;
}

.board_form_actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #e1e7ec;
}

@media (max-width: 760px) {
  .boards_container {
    width: calc(100% - 28px);
    padding-block: 24px 38px;
  }

  .boards_header,
  .boards_catalog_heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .board_cards {
    grid-template-columns: 1fr;
  }

  .board_form_panel {
    padding: 20px;
  }
}

@media (max-width: 380px) {
  .board_stats div {
    padding: 12px 8px;
  }

  .board_stats dd {
    font-size: 20px;
  }

  .board_breakdown dl {
    grid-template-columns: 1fr;
  }

  .board_form_dimensions {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

#cell_set {
  .boards_header h1 {
    overflow-wrap: anywhere;
  }

  #board_show {
    margin: 0;
  }

  #board_show #play_area #game_board {
    display: block;
    width: max-content;
    margin-inline: auto;
    border: 5px solid #263442;
    border-radius: 5px;
    background: #263442;
    box-shadow: 0 3px 10px rgba(25, 48, 68, 0.18);

    .cell {
      flex: none;
      cursor: default;
    }
  }
}

.board_preview_panel {
  min-width: 0;
  margin-bottom: 24px;
  border: 1px solid #d5dee6;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(25, 48, 68, 0.07);
}

.board_preview_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid #dce4ea;

  h2 {
    margin: 0;
    font-size: 25px;
    font-weight: 400;
  }
}

.board_preview_canvas {
  overflow-x: auto;
  padding: 28px 20px;
}

.board_preview_hint {
  margin: 0;
  padding: 18px 24px;
  border-top: 1px solid #dce4ea;
  color: #647181;
  font-size: 13px;
  line-height: 1.5;
}

.board_resize_panel .board_form_dimensions {
  margin-top: 0;
}

.board_resize_hint {
  margin: 20px 0 0;
  color: #647181;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .board_preview_header,
  .board_preview_hint {
    padding-inline: 20px;
  }
}

#edit_board {
  #dialog-confirm {
    display: none;
  }

  .boards_header p {
    overflow-wrap: anywhere;
  }

  #board_show {
    margin: 0;
  }

  #board_show #play_area #game_board {
    display: block;
    min-width: 0;
    border: 0;
    background: #fff;

    .draggable_cells {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 12px;
      box-sizing: border-box;
      padding: 20px;
      border-block: 1px solid #dce4ea;
      background: #f8fafc;
    }

    .cell {
      flex: none;
      cursor: grab;
    }

    .cell.ui-draggable-dragging {
      cursor: grabbing;
    }

    .editable_cell.hovered {
      outline: 2px solid #29b6f6;
      outline-offset: -2px;
    }

    .board {
      width: max-content;
      margin-inline: auto;
      border: 5px solid #263442;
      border-radius: 5px;
      background: #263442;
      box-shadow: 0 3px 10px rgba(25, 48, 68, 0.18);
    }
  }
}

.board_editor_navigation,
.board_editor_tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.board_editor_settings {
  max-width: none;
  margin-bottom: 20px;
}

.board_editor_settings_fields {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 20px;

  .board_form_field {
    flex: 1 1 280px;
  }
}

.board_editor_active {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: #526171;
  font-size: 14px;

  input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #1686bb;
  }
}

.board_editor_workspace {
  min-width: 0;
  border: 1px solid #d5dee6;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(25, 48, 68, 0.07);
}

.board_editor_workspace_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding: 24px 24px 12px;

  h2 {
    margin: 0 0 6px;
    font-size: 25px;
    font-weight: 400;
  }

  p {
    margin: 0;
    color: #647181;
    font-size: 14px;
    line-height: 1.5;
  }
}

.board_editor_tools .boards_secondary_action {
  min-height: 36px;
  padding-inline: 11px;
  font: 13px Arial, sans-serif;
  box-shadow: none;
}

.board_editor_tools .board_editor_clear {
  border-color: #e5bbc2;
  color: #a43343;

  &:hover {
    border-color: #c97984;
    background: #fff3f4;
    color: #8e2635;
  }
}

.board_editor_tool_hint {
  margin: 0;
  padding: 0 24px 20px;
  color: #647181;
  font-size: 13px;
  line-height: 1.5;
}

.board_palette_item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 68px;
  color: #526171;
  font-size: 12px;
  line-height: 1.2;

  .cell.block {
    background: #263442;
    border: 1px dashed #aebdca;
  }
}

.board_editor_canvas {
  overflow-x: auto;
  padding: 28px 20px;
}

.board_editor_footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 24px;
  border-top: 1px solid #dce4ea;

  p {
    max-width: 580px;
    margin: 0;
    color: #647181;
    font-size: 13px;
    line-height: 1.5;
  }
}

.ui-dialog.board_clear_dialog {
  box-sizing: border-box;
  max-width: calc(100vw - 28px);
  padding: 20px;
  border: 1px solid #d5dee6;
  border-radius: 12px;
  background: #fff;
  color: #263746;
  box-shadow: 0 12px 40px rgba(25, 48, 68, 0.25);

  p {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.5;
  }

  .ui-dialog-buttonset {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  button {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #aebdca;
    border-radius: 8px;
    background: #f8fafc;
    color: #34475a;
    cursor: pointer;
    font: 15px 'Acme';

    &:hover {
      background: #eef5f8;
    }

    &:focus-visible {
      outline: 2px solid #176b96;
      outline-offset: 2px;
    }
  }
}

@media (max-width: 760px) {
  .board_editor_workspace_header {
    padding: 20px 20px 12px;
  }

  .board_editor_tool_hint {
    padding-inline: 20px;
  }

  .board_editor_footer {
    padding: 18px 20px;
  }
}

.ui-dialog {
  background: white;
  border:1px solid silver;
  box-shadow: 0 0 5px rgba(0,0,0,0.5);
  padding: 10px;
  height: 40px;
}

.ui-dialog-titlebar {
  display: none;
}
