#game-market-tables-view {
  width: 100%;
  max-width: 44rem;
  height: min(64rem, var(--app-sheet-height));
  transition: height var(--viewkit-transition-duration) ease-in-out,
    translate var(--viewkit-transition-duration) ease-in-out,
    box-shadow var(--viewkit-transition-duration) ease-in-out,
    border-radius var(--viewkit-transition-duration) ease-in-out;

  @media (width >= 680px) and (height >= 620px) {
    &:not([hidden]) {
      border-radius: var(--sheet-border-radius);
      --viewkit-sheet-offset-y: var(--viewkit-sheet-centered-offset-y);
    }
  }

  > #tables-list-panel {
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    padding: 0;
    overflow-y: auto;
  }
  #tables-list-panel > form { flex: 1 0 auto; grid-template-rows: auto 1fr; }
  form { display: grid; gap: 0.8rem; }
  fieldset { min-width: 0; border: 0; }
  .table-section { display: grid; }
  .table-section:has(> .tables) { grid-template-rows: auto 1fr; }
  .table-section > h2 {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 3.2rem;
    padding-inline: 1.2rem;
    background: var(--viewkit-light-background);
    font-weight: 600;
  }
  .table-count { color: var(--color-gray); font-size: 1.3rem; font-weight: 400; }
  .tables { list-style: none; }
  .tables { border-top: 1px solid var(--toolbar-border-color); }
  .tables:empty { border-top: 0; }
  .tables > li + li { border-top: 1px solid var(--toolbar-border-color); }
  .tables > li { position: relative; }
  .tables > .created .table { animation: table-created-highlight 1s ease 0.2s backwards; }
  .tables > .moved .table { animation: table-highlight 1s ease 0.46s backwards; }
  .table {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--viewkit-light-background);
  }
  .summary {
    display: grid;
    flex: 1;
    min-width: 0;
    height: auto;
    min-height: 5.2rem;
    padding: 0.4rem 1.2rem;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.8rem;
    align-items: center;
    align-content: center;
    text-align: left;
    justify-content: normal;
    line-height: 1.3;
    background: transparent;
    border-radius: 0;
    font-weight: 400;
  }
  .defaults-summary { min-height: calc(5.2rem + 1px); border-bottom: 1px solid var(--toolbar-border-color); }
  .summary span { text-box: normal; }
  .caption { display: grid; gap: 0.2rem; min-width: 0; font-weight: 400; line-height: 1.2; }
  .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .state { color: var(--color-gray); font-size: 1.2rem; font-weight: 400; }
  .state:empty { display: none; }
  .description { color: var(--color-gray); font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .chevron { width: 2.4rem; height: 2.4rem; color: var(--color-gray); }
  .table:has(.actions:not([hidden])) .description { margin-right: 9.2rem; }
  .invalid .description { color: var(--color-red); }
  .actions:not([hidden]) { position: absolute; right: 4.4rem; display: flex; }
  .reorder { display: flex; border-radius: 100vmax; overflow: hidden; }
  .reorder button { border-radius: 0; }
  .reorder:has(button:disabled) button:not(:disabled) { border-radius: 100vmax; }
  .editor[hidden] { display: none; }
  > [purpose="slide"] { max-width: none; height: 100%; }
  .save:not(:disabled) { color: var(--color-blue); }
  .access { padding-inline: 1.2rem; color: var(--color-gray); font-size: 1.3rem; }
  .access:empty { display: none; }
  input.form-control { background-color: var(--viewkit-light-background); }
  input:disabled { opacity: 1; color: inherit; }
  > .\@error { padding: 1.6rem; }
}

@keyframes table-created-highlight {
  from { background-color: var(--color-blue); }
  to { background-color: var(--viewkit-light-background); }
}

@keyframes table-highlight {
  from { background-color: color-mix(in srgb, var(--color-blue) 20%, var(--viewkit-light-background)); }
  to { background-color: var(--viewkit-light-background); }
}

#game-market-table-editor-view {
  > main { padding: 1.6rem; }
  .editor { border: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.6rem 1.2rem; }
  .active { display: flex; justify-content: flex-start; align-self: end; min-height: 3.6rem; gap: 0.8rem; font-size: 1.3rem; }
  .active > span { text-box: normal; }
  .small-only { grid-column: 1 / -1; justify-content: flex-start; }
  .small-only[hidden] { display: none; }
  input.form-control { background: var(--viewkit-light-background); }
  input:disabled { opacity: 1; color: inherit; }
  .remove:not(:disabled) { color: var(--color-red); }

}

#game-market-tables-view {
  > #tables-room-panel { display: grid; grid-template-rows: minmax(0, 1fr); overflow: hidden; position: relative; }

  .room-scroll {
    overflow: auto;
    overscroll-behavior: contain;
    /* WebKit scrollbar paint-order workaround: https://bugs.webkit.org/show_bug.cgi?id=273638 */
    will-change: z-index;
  }
  .room-canvas { position: relative; min-width: 100%; min-height: 100%; background-image: radial-gradient(circle, var(--toolbar-border-color) 1px, transparent 1px); background-size: 12px 12px; background-position: -6px -6px; transition: width 260ms ease, height 260ms ease; }
  .room-canvas:has(.dragging) { transition: none; }
  .room-canvas, .room-canvas * { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
  .room-table { --room-radius: 0.8rem; position: absolute; border: 1px solid var(--color-gray); border-radius: var(--room-radius); background: white; scroll-margin: 12px; }
  .room-table.inactive { border-style: dashed; background: var(--toolbar-background-color); }
  .room-table.selected { outline: 2px solid var(--color-blue); outline-offset: 2px; z-index: 1; }
  .room-table.dragging { z-index: 2; }
  .room-move { display: grid; gap: 0.2rem; align-content: center; width: 100%; height: 100%; padding: 0.4rem; background: transparent; border-radius: inherit; font-weight: 400; touch-action: auto; user-select: none; -webkit-user-select: none; cursor: grab; }
  .room-table.selected :is(.room-move:not([aria-disabled="true"]), .room-resize) { touch-action: none; }
  .room-move[aria-disabled="true"] { color: inherit; cursor: default; }
  .dragging .room-move { cursor: grabbing; }
  /* Hit the move button directly, not its clipped text containers. */
  .room-move > span { text-box: normal; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
  .room-fill { font-size: 1.2rem; color: var(--color-gray); }
  .room-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; min-width: 0; padding: 0; border-radius: 0 0 calc(var(--room-radius) - 1px) 0; background: transparent; cursor: nwse-resize; touch-action: auto; }
  .room-resize::after { content: ''; position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px; border-bottom-right-radius: calc(var(--room-radius) - 1px - 2px); border-right: 2px solid color-mix(in srgb, var(--color-gray) 65%, white); border-bottom: 2px solid color-mix(in srgb, var(--color-gray) 65%, white); }
  .room-empty { position: absolute; top: 50%; width: 100%; text-align: center; pointer-events: none; color: var(--color-gray); }
  .room-empty[hidden] { display: none; }
  .room-table.created { animation: table-created-highlight 1s ease 0.2s backwards; }
  #room-instructions, .room-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  @media (prefers-reduced-motion: reduce) {
    .room-canvas { transition: none; }
  }
}
